-
-
Save suziwen/6a309735e770e4bc3490 to your computer and use it in GitHub Desktop.
Nginx add_header
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
# Nginx will fail to start and will throw an error like this: | |
# Reloading nginx configuration: nginx: [emerg] "add_header" directive is not allowed here in /etc/nginx/sites-enabled/fail1.conf:39 | |
server { | |
listen 8080 default; | |
server_name _; | |
root /var/www/html ; | |
if ($http_host = 'evan.com') { | |
add_header 'X-Evan-A' '1'; | |
} | |
location / { | |
} | |
} |
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
# This works | |
server { | |
listen 8080 default; | |
server_name _; | |
root /var/www/html ; | |
add_header 'X-Evan-A' '1'; | |
location / { | |
} | |
} |
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
# This works | |
server { | |
listen 8080 default; | |
server_name _; | |
root /var/www/html ; | |
location / { | |
if ($http_host = 'evan.com') { | |
add_header 'X-Evan-A' '1'; | |
} | |
} | |
} |
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
# This works | |
server { | |
listen 8080 default; | |
server_name _; | |
root /var/www/html ; | |
location / { | |
add_header 'X-Evan-A' '1'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment