NGINX try_files with multiple named locations

前端 未结 1 642
面向向阳花
面向向阳花 2020-12-14 03:30

I want to fetch a file from the cache conditionally, based on a custom header in the request.

If the X-Proxy header is present in the request, return th

相关标签:
1条回答
  • 2020-12-14 03:49

    try_files directive only accepts one named location, so apparently it goes for the last one. This blog post proposes a workaround that works in your case. In case you don't won't read the whole post, you can add the following lines at the end of @local block:

    proxy_intercept_errors on;
    recursive_error_pages on;
    error_page 404 = @remote;
    

    and change your try_files to this:

    try_files /$uri @local;
    
    0 讨论(0)
提交回复
热议问题