From f9793f5b9b0d6b7f4cf125624ae1e5e3024028fc Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Mon, 23 Oct 2023 22:46:45 -0600 Subject: [PATCH] Have two nginx basic configs --- ...bdomain.conf => subdomain_basic_root.conf} | 6 +---- nginx/subdomain_proxy.conf | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) rename nginx/{subdomain.conf => subdomain_basic_root.conf} (62%) create mode 100644 nginx/subdomain_proxy.conf diff --git a/nginx/subdomain.conf b/nginx/subdomain_basic_root.conf similarity index 62% rename from nginx/subdomain.conf rename to nginx/subdomain_basic_root.conf index 49a6bbe..35c8522 100644 --- a/nginx/subdomain.conf +++ b/nginx/subdomain_basic_root.conf @@ -1,4 +1,4 @@ -server { +server{ index index.html; root MY_ROOT; @@ -8,10 +8,6 @@ server { try_files $uri $uri/; } - if ($host = DOMAIN) { - return 301 https://$host$request_uri; - } # managed by Certbot - listen 80; listen [::]:80; return 404; # managed by Certbot diff --git a/nginx/subdomain_proxy.conf b/nginx/subdomain_proxy.conf new file mode 100644 index 0000000..6f835e2 --- /dev/null +++ b/nginx/subdomain_proxy.conf @@ -0,0 +1,27 @@ +server { + index index.html; + + # replace with sub-domain + server_name DOMAIN; + + location / { + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_redirect off; + proxy_buffering off; + # replace the port that's used for the internal app + proxy_pass http://127.0.0.1:PORT; + } + # temporary files required for certbot + location /.well_known/ { + # replace with root for temp files (usually /var/www/html/) + root MY_ROOT; + } + + listen 80; + listen [::]:80; + return 404; # managed by Certbot +}