Skip to content

Instantly share code, notes, and snippets.

@lextoumbourou
Created January 14, 2015 10:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lextoumbourou/d6221deb818da4f342ea to your computer and use it in GitHub Desktop.
Save lextoumbourou/d6221deb818da4f342ea to your computer and use it in GitHub Desktop.
Conditional Nginx error pages based on Accept (or other) headers
http {
map $http_accept $extension {
default html;
application/json json;
}
server {
listen 80;
error_page 500 /500;
location = /500 {
internal;
alias /var/www/error/403.$extension;
}
}
}
@stereobooster
Copy link

map $content_type $extension {
  default html;
  ~application/json json;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment