1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-06-30 22:05:46 +00:00

feat: Add proxy header X-Forwarded-Host

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
This commit is contained in:
浊酒
2021-12-10 13:08:18 +08:00
committed by Richard Hansen
parent 6f4f9ec20c
commit af877cf784
7 changed files with 50 additions and 1 deletions

View File

@ -155,6 +155,11 @@ map $http_x_forwarded_proto $proxy_x_forwarded_proto {
'' $scheme;
}
map $http_x_forwarded_host $proxy_x_forwarded_host {
default {{ if $trust_downstream_proxy }}$http_x_forwarded_host{{ else }}$http_host{{ end }};
'' $http_host;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
@ -212,6 +217,7 @@ proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;