From 8c58280409405be424d379feabe0d1bf51b0069e Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 15 Dec 2023 15:20:15 +1100 Subject: [PATCH] fix: Try multiple proxies --- nginx.conf | 77 +++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/nginx.conf b/nginx.conf index 94bd0bd..cbfe5c5 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,45 +1,40 @@ -upstream loadbalancer { - server doh.hnshosting.au:443 weight=1 max_fails=1 fail_timeout=30s; - server easyhandshake.com:8053 weight=1 max_fails=1 fail_timeout=30s; - server doh.hnsdns.com:443 weight=1 max_fails=1 fail_timeout=30s; - server hs.dnssec.dev:443 weight=1 max_fails=1 fail_timeout=30s; - server hnsns.net:443 weight=1 max_fails=1 fail_timeout=30s; +server { + listen 8001 default_server; + server_name web1.example.com; + location / { + proxy_pass https://doh.hnshosting.au; + proxy_set_header Host doh.hnshosting.au; + } } server { - listen 80; - server_name _; - - location / { - # Randomly select a host - set $upstream_host ""; - - if ($host ~* ^doh\.hnshosting\.au$) { - set $upstream_host doh.hnshosting.au; - } - if ($host ~* ^easyhandshake\.com$) { - set $upstream_host easyhandshake.com; - } - if ($host ~* ^doh\.hnsdns\.com$) { - set $upstream_host doh.hnsdns.com; - } - if ($host ~* ^hs\.dnssec\.dev$) { - set $upstream_host hs.dnssec.dev; - } - if ($host ~* ^hnsns\.net$) { - set $upstream_host hnsns.net; - } - - # Set proxy_pass based on the chosen upstream - proxy_pass https://$upstream_host$request_uri; - - proxy_ssl_verify off; - proxy_set_header X-Real-IP $remote_addr; - 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; - } + listen 8002 default_server; + server_name web2.example.com; + location / { + proxy_pass https://easyhandshake.com:8053; + proxy_set_header Host easyhandshake.com; + } +} + +server { + listen 8003 default_server; + server_name web3.example.com; + location / { + proxy_pass https://doh.hnsdns.com; + proxy_set_header Host doh.hnsdns.com; + } +} + +upstream main { + server 127.0.0.1:8001; + server 127.0.0.1:8002; + server 127.0.0.1:8003; +} + +server { + listen 80; + server_name _; + location / { + proxy_pass http://main; + } }