On 21 January 2014 13:59, WheresWardy <nginx-fo...@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

Reply via email to