为什么将error_page重写到命名位置并不起作用?

时间:2017-07-19 22:05:19

标签: nginx

考虑nginx设置:

server {
    server_name abc.com;
    listen 80;

    location @namedlocation {
        proxy_pass google.com;
    }
    location ~ /some/url {
        rewrite /some/url /another/url break;
        error_page 418 = @namedlocation;
        return 418; 
    }
}

如果我要求abc.com/some/url,则proxy_pass到google.com/another/url不起作用。但是如果我使用try_files指令

server {
    server_name abc.com;
    listen 80;

    location @namedlocation {
        proxy_pass google.com;
    }
    location ~ /some/url {
        rewrite /some/url /another/url break;
        try_files /NotImportantPath/ @namedlocation; 
    }
}

确实如此。能否解释一下这种行为的原因是什么?

0 个答案:

没有答案