test chat gpt's solution
All checks were successful
Build Docker / Build Docker (push) Successful in 24s

This commit is contained in:
Nathan Woodburn 2023-12-15 15:03:56 +11:00
parent 6e7bff2d18
commit 1042d4a4f5
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -14,22 +14,40 @@ map $host $upstream {
~^hnsns\.net$ hnsns.net; ~^hnsns\.net$ hnsns.net;
} }
server { server {
listen 80; listen 80;
# Catch all servers
server_name _; server_name _;
location / { location / {
# Dynamically set the Host header based on the chosen upstream
set $upstream_host "";
proxy_pass https://$upstream; 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;
}
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_ssl_verify off;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; 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 $upstream_addr;
} }
} }