Skip to content

Commit dfd08a7

Browse files
committed
feat: Nginx configurable X-Forwarded-Port
Signed-off-by: Fabian 'xx4h' Sylvester <xx4h@xx4h.de>
1 parent 4ae4f1e commit dfd08a7

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

nginx/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ ENV \
183183
MODSEC_UPLOAD_KEEP_FILES=Off \
184184
NGINX_ALWAYS_TLS_REDIRECT=off \
185185
NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx \
186+
NGINX_X_FORWARDED_PORT='$server_port' \
186187
NGINX_X_FORWARDED_PROTO='$scheme' \
187188
PORT=8080 \
188189
PROXY_SSL_CERT_FILE=/etc/nginx/conf/proxy.crt \

nginx/Dockerfile-alpine

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ ENV \
184184
MODSEC_UPLOAD_KEEP_FILES=Off \
185185
NGINX_ALWAYS_TLS_REDIRECT=off \
186186
NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx \
187+
NGINX_X_FORWARDED_PORT='$server_port' \
187188
NGINX_X_FORWARDED_PROTO='$scheme' \
188189
PORT=8080 \
189190
PROXY_SSL_CERT_FILE=/etc/nginx/conf/proxy.crt \

nginx/templates/includes/proxy_backend.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ proxy_set_header Upgrade $http_upgrade;
44
proxy_set_header Connection $connection_upgrade;
55
proxy_set_header ${REAL_IP_PROXY_HEADER} $remote_addr;
66
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
7-
proxy_set_header X-Forwarded-Port $server_port;
7+
proxy_set_header X-Forwarded-Port ${NGINX_X_FORWARDED_PORT};
88
proxy_set_header X-Forwarded-Proto ${NGINX_X_FORWARDED_PROTO};
99

1010
proxy_http_version 1.1;

0 commit comments

Comments
 (0)