Nginx:在连接到上游时,抛出自定义上游错误页面

时间:2017-05-05 03:07:01

标签: nginx custom-error-pages nginx-location

以下是我在Nginx中的上游块

upstream sample{
    server abc1.example.com down;
    server abd2.example.com down;
}

在这种情况下,错误日志显示以下错误:

no live upstreams while connecting to upstream, client: 10.196.90.83, server: abc_sample_a , request: "GET / HTTP/1.1", upstream: "http://sample/", host: "abc_sample_a

目前,收到的错误代码是502.但我想返回503错误代码。

1 个答案:

答案 0 :(得分:1)

这应该有效:

server {
  ...
  error_page 502 = @fallback;

  ...

  location @fallback {
    return 503;
  }
}