From 304bbf59e1c400565fe93a98e2f9682d08c1abf8 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 15 Dec 2023 15:14:07 +1100 Subject: [PATCH] try chatgpt again --- nginx.conf | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/nginx.conf b/nginx.conf index 8301072..45dc3c6 100644 --- a/nginx.conf +++ b/nginx.conf @@ -6,27 +6,42 @@ upstream loadbalancer { server hnsns.net:443 weight=1 max_fails=1 fail_timeout=30s; } - server { listen 80; - # Catch all servers server_name _; location / { - # Get upstream host + # Randomly select a host set $upstream_host ""; - # Randomly select a host - set $upstream_host loadbalancer; + 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; + } + + # Use the named location without the @ prefix + proxy_pass https://dynamic_upstream; + } + + location dynamic_upstream { + # Use a named location to set proxy_pass dynamically proxy_pass https://$upstream_host; 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; - } }