(从服务器故障交叉发布)
我们有一个nginx(OpenResty 1.4.2.7)实例充当负载均衡器。它有两个服务器指令,一个用于服务一个特定站点(让我们称之为www.our-special-host.com)和一个通配符用于其他所有站点。我们正在尝试对其进行配置,以便显示不同的502错误页面,具体取决于两个服务器指令的后端中断了哪一个。
我们的配置适用于HTTP,但不适用于HTTPS。如果我们关闭后端并点击www.our-special-host.com,我们会收到HTTP和HTTPS的相应错误。但是,如果我们访问任何其他托管网站,我们会获得HTTP的正确错误页面,但对于HTTPS,我们会收到www.our-special-host.com的错误页面。
这是我们的配置(轻微编辑):
server {
server_name www.our-special-host.com
listen 80;
listen 443 ssl;
error_page 502 /nginx_errors/loadbalancer_502_on_special_host.html;
location /nginx_errors/ {
alias /path/to/nginx_errors/;
}
location / {
proxy_pass x.x.x.x;
...
}
ssl_certificate certificate.crt;
ssl_certificate_key pk.key;
}
server {
listen 80;
listen 443 ssl;
error_page 502 /nginx_errors/loadbalancer_502_on_other_hosts.html;
location /nginx_errors/ {
alias /path/to/nginx_errors/;
}
location / {
proxy_pass y.y.y.y;
...
}
ssl_certificate certificate.crt;
ssl_certificate_key pk.key;
}
(所有相关主机均为XXX.ourdomain.com,证书适用于* .ourdomain.com。)
我们还尝试向第二个服务器块添加一个显式的catch-all正则表达式,即
server_name ~^.*$;
这种行为仍然是错误的,但不一样的错误: