From 0d1d52f400820ff126ceb1ac7faaca2668a48723 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 21 Nov 2023 17:54:44 +0000 Subject: [PATCH] Update nginx.conf --- nginx.conf | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/nginx.conf b/nginx.conf index 24c5b9c..f7ec74c 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,6 +8,12 @@ events { http { default_type application/octet-stream; + # Maps for handling WebSocket connections + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + server { listen 80; @@ -24,23 +30,21 @@ http { } location / { - # Use the placeholders for the proxy pass - proxy_pass ${PROTOCOL}://${BACKEND_ADDRESS}:${BACKEND_PORT}; + # Proxy pass to the backend using environment variables + proxy_pass http://${BACKEND_ADDRESS}:${BACKEND_PORT}; # Always use http for the backend connection + + # General proxy settings proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; + proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; 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; # Inform the backend about the original protocol + # Do not use X-Forwarded-Proto to hide the SSL usage from the backend proxy_set_header Accept-Encoding ""; proxy_buffering off; - proxy_ssl_verify off; # Skip SSL verification, be cautious - - # Redirect HTTP to HTTPS - if ($scheme != "https") { - return 301 https://$host$request_uri; - } + # Skip SSL verification if you are proxying to an HTTPS backend, though this is typically not recommended + proxy_ssl_verify off; } } }