fix: Try multiple proxies
All checks were successful
Build Docker / Build Docker (push) Successful in 24s

This commit is contained in:
Nathan Woodburn 2023-12-15 15:20:15 +11:00
parent da06f7090e
commit 8c58280409
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -1,45 +1,40 @@
upstream loadbalancer { server {
server doh.hnshosting.au:443 weight=1 max_fails=1 fail_timeout=30s; listen 8001 default_server;
server easyhandshake.com:8053 weight=1 max_fails=1 fail_timeout=30s; server_name web1.example.com;
server doh.hnsdns.com:443 weight=1 max_fails=1 fail_timeout=30s; location / {
server hs.dnssec.dev:443 weight=1 max_fails=1 fail_timeout=30s; proxy_pass https://doh.hnshosting.au;
server hnsns.net:443 weight=1 max_fails=1 fail_timeout=30s; proxy_set_header Host doh.hnshosting.au;
}
} }
server { server {
listen 80; listen 8002 default_server;
server_name _; server_name web2.example.com;
location / {
location / { proxy_pass https://easyhandshake.com:8053;
# Randomly select a host proxy_set_header Host easyhandshake.com;
set $upstream_host ""; }
}
if ($host ~* ^doh\.hnshosting\.au$) {
set $upstream_host doh.hnshosting.au; server {
} listen 8003 default_server;
if ($host ~* ^easyhandshake\.com$) { server_name web3.example.com;
set $upstream_host easyhandshake.com; location / {
} proxy_pass https://doh.hnsdns.com;
if ($host ~* ^doh\.hnsdns\.com$) { proxy_set_header Host doh.hnsdns.com;
set $upstream_host doh.hnsdns.com; }
} }
if ($host ~* ^hs\.dnssec\.dev$) {
set $upstream_host hs.dnssec.dev; upstream main {
} server 127.0.0.1:8001;
if ($host ~* ^hnsns\.net$) { server 127.0.0.1:8002;
set $upstream_host hnsns.net; server 127.0.0.1:8003;
} }
# Set proxy_pass based on the chosen upstream server {
proxy_pass https://$upstream_host$request_uri; listen 80;
server_name _;
proxy_ssl_verify off; location / {
proxy_set_header X-Real-IP $remote_addr; proxy_pass http://main;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
proxy_set_header X-Forwarded-Proto $scheme;
# Show which node served the request in logs
add_header X-Load-Balancer-Node $upstream_addr;
add_header X-Load-Balancer-Node-Name $upstream_host;
}
} }