在nginx中,我成功地使用了upstream
组和proxy_next_upstream
来捕获主服务器上的错误,并将其移交给备用服务器。
我想记录从主服务器返回的错误,以便对它们发出警报。该怎么办?
这是配置的样子:
http {
.
.
.
upstream myhost {
server example.com max_fails=1 fail_timeout=10;
server unix:\0myhost_backup backup;
}
server {
listen unix:\0myhost_backup;
access_log /logs/myhost_backup.access.log access_tsv buffer=32k flush=1m;
error_log /logs/myhost_backup.error.log;
location / {
return 200 "OK"; #mock response
}
}}
server {
.
.
.
location / {
internal;
set $endpoint https://myhost;
proxy_pass $endpoint$request_uri;
proxy_next_upstream error timeout invalid_header http_500;
}