Skip to content

Instantly share code, notes, and snippets.

@suziwen
Forked from evandhoffman/fail1.conf
Created September 23, 2015 17:06
Show Gist options
  • Save suziwen/6a309735e770e4bc3490 to your computer and use it in GitHub Desktop.
Save suziwen/6a309735e770e4bc3490 to your computer and use it in GitHub Desktop.
Nginx add_header
# 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 works
server {
listen 8080 default;
server_name _;
root /var/www/html ;
add_header 'X-Evan-A' '1';
location / {
}
}
# 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 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