Created
November 13, 2017 19:44
-
-
Save benspaulding/599fd5e49155d8a84827a79fc5f510c2 to your computer and use it in GitHub Desktop.
Send nginx server port in host header to upstream only when port is non-standard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send nginx server port in host header to upstream only when port is non-standard. | |
# Requires nginx >= 0.9.0 | |
map $server_port $host_port { | |
default $:port; | |
80 ''; | |
443 ''; | |
} | |
server { | |
... | |
set $:port :$server_port; | |
location @proxy { | |
... | |
proxy_set_header Host $host$host_port; | |
... | |
} | |
... | |
} | |
# Requires nginx >= 1.11.0 | |
on nginx < 1.11 | |
map $server_port $host_port { | |
default :$server_port; | |
80 ''; | |
443 ''; | |
} | |
server { | |
... | |
location @proxy { | |
... | |
proxy_set_header Host $host$host_port; | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment