Skip to content

Commit 1d2f130

Browse files
committed
Pass through X-Forwarded-Host if set
1 parent ca36161 commit 1d2f130

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

config/http.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ http {
2121
port_in_redirect off;
2222
server_tokens off;
2323

24+
# If we receive X-Forwarded-Host, pass it through; otherwise, pass along the
25+
# host used to connect to this server
26+
map $http_x_forwarded_host $proxy_x_forwarded_host {
27+
default $http_x_forwarded_host;
28+
'' $host;
29+
}
30+
2431
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
2532
# scheme used to connect to this server
2633
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
@@ -69,7 +76,7 @@ http {
6976
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
7077
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
7178
proxy_set_header X-Request-ID $proxy_x_request_id;
72-
proxy_set_header X-Forwarded-Host $host;
79+
proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
7380

7481
include /etc/nginx/app.conf;
7582

0 commit comments

Comments
 (0)