On Fri, Sep 17, 2021 at 02:36:11PM -0300, Fabiano Furtado Pessoa Coelho wrote: > On Thu, Sep 16, 2021 at 7:37 PM Francis Daly wrote: > > On Thu, Sep 16, 2021 at 04:25:59PM -0300, Fabiano Furtado Pessoa Coelho > > wrote:
Hi there, > > > 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. > > I think I will "put the common pieces (apart from proxy_pass) outside > the location{}s". > This is the best config for me! Good to hear that you found a configuration that works for you :-) Once you understand how nginx uses its config, and how directive inheritance works, then you won't be surprised by the behaviour you configured. (With a few exceptions, often related to the rewrite module, the general pattern is: one request is handled in one location{}; and each directive *not* explicit in that location either inherits from the surrounding context, or does not inherit at all. And a directive is something like "proxy_set_header", not "proxy_set_header X-Real-IP".) Good luck with it, f -- Francis Daly fran...@daoine.org _______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx