【问题标题】:Have custom Nginx error page when All backend servers unhealty当所有后端服务器不健康时有自定义 Nginx 错误页面
【发布时间】:2014-12-30 17:22:10
【问题描述】:

我在生产环境中使用 Nginx Plus AWS EC2 映像。 我使用健康检查模块来查看后端服务器的可用性。当所有服务器都不健康时。然后 nginx 返回一个 404 错误屏幕。

我找不到相应的 HTML。我需要配置它。

任何想法我怎么能找到它?

谢谢

【问题讨论】:

    标签: amazon-web-services nginx amazon-ec2 production-environment


    【解决方案1】:

    您可以使用proxy_next_upstream [1] 指定将请求传递到下一个后端的情况,例如502错误等。当后端不可用,或使用proxy_next_upstream时全部不可用时,会返回502错误。您可以指定在这种情况下提供哪个文件。

    location / {
            proxy_pass http://backend;
            error_page 502 /50x.html;
        }
    

    为 50x.html 定义位置,否则它将回到“/”位置。

    location /50x.html {
        }
    

    [1]http://nginx.org/r/proxy_next_upstream

    注意:NGINX Plus 附带商业支持。要访问支持,请访问 http://nginx.com/ami-support-activation 并输入您的 AWS 帐号。

    【讨论】:

      猜你喜欢
      • 2023-01-24
      • 2023-04-01
      • 2019-06-28
      • 2020-12-19
      • 2020-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多