问题原文
原帖链接 · ender ulusoy · CC BY-SA 3.0
We have a NGINX reverse proxy (clustered) with 45 upstreams (22 domains, 20 subdomains, 11 apps).
Some of our projects hosts apis for some users globally.
Our developers designed special custom 500 responses for special cases and want to show that messages only for tomcat_api upstream.
They want to serve 500 pages and handle exceptions on tomcat_api upstream members not on NGINX. But we want to handle all other 5xx errors on NGINX.
As I can not succeeded need a hand right now.
Here is the server configuration follows, could you please help?
server {
server_name api.hotcoldwarm.com;
location / {
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header x-redirect-uri hotcoldwarm;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; always";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://tomcat_api;
proxy_next_upstream error timeout http_502 http_503 http_504 http_404;
proxy_connect_timeout 1;
}
listen 80;
listen 443 ssl;
ssl_certificate /etc/rapidssl/live/api.hotcoldwarm.com/fullchain.pem;
ssl_certificate_key /etc/rapidssl/live/api.hotcoldwarm.com/privkey.pem;
include /etc/rapidssl/options-ssl-nginx.conf;
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
Thank you.
已采纳解答
原帖链接 · ont.rif · CC BY-SA 3.0
You probably want to consider proxy_intercept_errors on; option. Then configure custom error_page after it. See answer https://stackoverflow.com/a/8715597/434255
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
