Welcome! Log In Create A New Profile

Advanced

Re: Nested location block for merging config returns 404?

Jonathan Matthews
January 21, 2014 09:12AM
On 21 January 2014 13:59, WheresWardy <nginx-forum@nginx.us> wrote:
>> Your line
>>
>> location \.(txt|css) {
>>
>> looks like a regex, but you're not telling nginx it /is/ a regex. I
>> wouldn't expect anything to work until you fix that.
>
> Apologies, that was a typo during simplification of my config. I do indeed
> have a ~ in my nested location block, and it's definitely matching
> correctly.
>
> Everything else you've specified seems to fit my observed behaviour, so
> think it's just that my use case doesn't fit with the inheritance rules as
> they stand. Thanks for your help!

No problem. You could look at using a map to achieve the config
deduplication you're aiming for. Something like this (typed, but not
tested or syntax-checked!)

------------------------------------
http {
map $uri $map_output {
default "";
~ \.txt "value2";
~ \.css "value2";
}
server {
location ~ /(dir1/)?dir2/ {
add_header X-My-Header value1;
add_header X-My-Static $map_output;
proxy_pass http://myproxy;
}
}
}
------------------------------------

This will also have the effect of wiping out inbound X-My-Static
headers, which you could get round by referencing them in the default
map output if you really needed them to be passed through ...

Jonathan

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nested location block for merging config returns 404?

WheresWardy January 21, 2014 08:29AM

Re: Nested location block for merging config returns 404?

Jonathan Matthews January 21, 2014 08:36AM

Re: Nested location block for merging config returns 404?

WheresWardy January 21, 2014 08:40AM

Re: Nested location block for merging config returns 404?

Jonathan Matthews January 21, 2014 08:50AM

Re: Nested location block for merging config returns 404?

WheresWardy January 21, 2014 08:59AM

Re: Nested location block for merging config returns 404?

Jonathan Matthews January 21, 2014 09:12AM

Re: Nested location block for merging config returns 404?

Valentin V. Bartenev January 21, 2014 11:26AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 82
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready