我正在使用ngnix根据cookie值将stream量路由到正确的应用程序服务器。 所以一个用户总是登陆一个特定的上游服务器。
现在我有多个这样的uptsream服务器。 当我为了维护目的而将其取下时,我想向上游服务器发送503。 什么是最简单的方法呢?
如果应用程序服务器崩溃,我们应该得到正常的“无法连接到后端”错误。 所以,只有当我故意把它放下时,我才应该得到上游的503。
我假设你想发送503页而不是503状态码。 如果前者,你可以为特定的http,服务器或位置configuration块添加一个error_page行:
location / { proxy_intercept_errors on; # this line may not be needed error_page 503 /var/www/errors/status-503.html # rest of your config here }