From fed59a7f4b64dcdec1461f1fbcb154eadb21ee9e Mon Sep 17 00:00:00 2001 From: Osama Shaikh <31347530+0samashaikh@users.noreply.github.com> Date: Sat, 21 Feb 2026 15:28:52 +0000 Subject: [PATCH] fix(nginx): forward correct proto/origin for socket.io behind proxy --- resources/core/nginx/nginx-template.conf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/core/nginx/nginx-template.conf b/resources/core/nginx/nginx-template.conf index ded97c94..6ce77180 100644 --- a/resources/core/nginx/nginx-template.conf +++ b/resources/core/nginx/nginx-template.conf @@ -6,6 +6,12 @@ upstream socketio-server { server ${SOCKETIO} fail_timeout=0; } +# Parse the X-Forwarded-Proto header - if set - defaulting to $scheme. +map $http_x_forwarded_proto $proxy_x_forwarded_proto { + default $scheme; + https https; +} + server { listen 8080; server_name ${FRAPPE_SITE_NAME_HEADER}; @@ -36,10 +42,12 @@ server { location /socket.io { proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Frappe-Site-Name ${FRAPPE_SITE_NAME_HEADER}; - proxy_set_header Origin $scheme://$http_host; + proxy_set_header Origin $proxy_x_forwarded_proto://${FRAPPE_SITE_NAME_HEADER}; proxy_set_header Host $host; proxy_pass http://socketio-server;