【发布时间】:2018-04-29 23:24:19
【问题描述】:
我正在尝试将我的所有 404 请求代理到备用服务器,也适用于主机服务器的 php 脚本返回的 404。
recursive_error_pages off;
error_page 404 = @missing;
location @missing {
proxy_pass http://anotherserver;
proxy_read_timeout 60s;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php$is_args$args;
}
所以每当 php 应用程序返回 404 时,它都会优雅地回退到另一个服务器,但问题是它无法传递 URI,因为它位于命名块内。
如何配置 nginx 仅在主机服务器的应用程序返回 404 时代理到 另一个服务器?
【问题讨论】:
-
你试过nginx upstream。 PS:我认为这是一个更适合超级用户或服务器故障的问题