"proxy_intercept_errors on" with @location setup
Francis Daly
francis at daoine.org
Thu Sep 16 22:37:42 UTC 2021
On Thu, Sep 16, 2021 at 04:25:59PM -0300, Fabiano Furtado Pessoa Coelho wrote:
Hi there,
> Is it possible to use "proxy_intercept_errors on" with @location?
Yes; but it is only useful if "proxy_pass" sees the
"proxy_intercept_errors". Which means: if the config directives are in,
or are inherited into, the location{} where the request is handled.
> Invalid config:
This looks like valid nginx config to me.
I guess you mean "does not do what I want", rather than "is rejected by
nginx as invalid"?
> The only valid configuration I've found to intercept errors is not
> using the @location but I want to use it to simplify the
> configuration.
Depending on how you understand "simplify" -- you could potentially
"include" a file with the common pieces and just have the unique
directives in each location{}; or you could put the common pieces (apart
from proxy_pass) outside the location{}s, and just have the unique
directives and proxy_pass inside the location{}s (note: your current
example has the same set of proxy_set_header directives in each
location{}, so this can work); or potentially you could use an external
macro-processing tool to generate your complicated nginx.conf from
whatever simplified input you want to use.
In general, nginx's config is fast for nginx to read and process; it
does not particularly try to be compact for people to write if there
are different configs wanted.
Hopefully you'll find a config setup that you're happy with.
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list