-
-
Save weapp/9a3fd2c068cb206e9d40 to your computer and use it in GitHub Desktop.
This file contains 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
map $status $error_msg { | |
default ""; | |
500 "Internal Server Error"; | |
502 "Bad Gateway"; | |
503 "Service Temporarily Unavailable"; | |
504 "Gateway Timeout"; | |
400 "Bad Request"; | |
401 "Unauthorized"; | |
403 "Forbidden"; | |
404 "Not Found"; | |
408 "Request Timeout"; | |
418 "I\'m a teapot"; | |
} | |
server { | |
listen 80; | |
server_name example.com; | |
root /home/manu/project/example; | |
index index.html; | |
error_page 400 401 403 404 408 418 500 502 503 504 /$status.json; | |
location /500 { return 500 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /502 { return 502 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /503 { return 503 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /504 { return 504 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /400 { return 400 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /401 { return 401 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /403 { return 403 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /404 { return 404 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /408 { return 408 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location /418 { return 418 '{"errors": [{"code": "$status", "message": "$error_msg"}]}'; } | |
location / { | |
proxy_pass http://rails; | |
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
proxy_redirect off; | |
proxy_buffering off; | |
proxy_set_header Host $http_host; | |
#proxy_set_header Host static.example.com; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_intercept_errors on; | |
} | |
} |
Author
weapp
commented
May 19, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment