I am interested in using a nesting of some sort so that I don't have to
duplicate all the proxy- and other directives for one "special case".
Basically, I'd like a very small subset of my webapp to also write to a
separate access-log. When a user hits that particular page, I would
like to log it, AND also perform all the directives for the rest of the
site that are already configured.
Something like
location /site {
location /site/search {
access_log /var/log/nginx/search_access.log;
}
proxy_pass ...
proxy_redirect off;
proxy_set_header ...
}
So accessing /site/search should write an entry in the "special log
file", and then do all the "normal stuff" that location /site has
itemized.
Is this possible?
Thanks again,
AJ
on 2012-09-26 04:06
on 2012-09-26 17:44
Hello! On Tue, Sep 25, 2012 at 10:05:44PM -0400, AJ Weber wrote: > > file", and then do all the "normal stuff" that location /site has > itemized. > > Is this possible? Not exactly. Each location is expected to have it's own "do something" list, i.e. if you need proxy_pass in this location - you have to write it explicitly. On the other hand, there is no need to duplicate normal configuration, e.g. proxy_redirect and proxy_set_header will be inherited from previous level(s). I.e. you have to write explicitly only few directives which aren't inherited, notably try_files, rewrite module directives, and content handlers like proxy_pass. In the above config snippet you have to duplicate proxy_pass into location /site/search. -- Maxim Dounin http://nginx.com/support.html
on 2012-09-26 21:01
OK, I am positive this is easy for you experienced nginx users! I have a backend app server setup and am using nginx for caching/proxy/ssl-termination. I would like to use the "default" server (listening on 443) to redirect the url https://host/monit to the server's monit-mini-http server (and continue to use it for ssl termination). so I need to direct the backend to http://localhost:2812/. Thus, I think I need a proxy_pass and a rewrite (to basically just remove "/monit" from the url (pass the remainder of the url back to monit's http server from root). I was trying to do this inside a location /monit { }. But, of course, I can't get it to work. :( Any hints?
on 2012-09-26 23:56
On 26 Set 2012 21h00 CEST, aweber@comcast.net wrote: > OK, I am positive this is easy for you experienced nginx users! > > I have a backend app server setup and am using nginx for > caching/proxy/ssl-termination. > > I would like to use the "default" server (listening on 443) to > redirect the url https://host/monit to the server's monit-mini-http > server (and continue to use it for ssl termination). so I need to > direct the backend to http://localhost:2812/. Very basic. No rewrites. location ^~ /monit { location ~* ^/monit/(?<monit_request_uri>.*)$ { proxy_pass http://127.0.0.1:2812/$monit_request_uri; proxy_set_header Host $host; } Feel free to add other headers to your liking. --- appa
on 2012-09-27 00:03
On 26 Set 2012 23h56 CEST, appa@perusio.net wrote: >> direct the backend to http://localhost:2812/. > > > Very basic. No rewrites. > > location ^~ /monit { > location ~* ^/monit/(?<monit_request_uri>.*)$ { > proxy_pass http://127.0.0.1:2812/$monit_request_uri; > proxy_set_header Host $host; > } Err, make that: location ^~ /monit { location ~* ^/monit(?<monit_request_uri>.*)$ { proxy_pass http://127.0.0.1:2812/$monit_request_uri; proxy_set_header Host $host; } This way https://myserver/monit won't give a 404. --- appa
on 2012-09-27 09:39
On Thu, Sep 27, 2012 at 12:02:35AM +0200, Antnio P. P. Almeida wrote: > >> redirect the url https://host/monit to the server's monit-mini-http > > } > > Err, make that: > > location ^~ /monit { > location ~* ^/monit(?<monit_request_uri>.*)$ { > proxy_pass http://127.0.0.1:2812/$monit_request_uri; > proxy_set_header Host $host; > } > > This way https://myserver/monit won't give a 404. The regex is not required: location ^~ /monit/ { proxy_pass http://127.0.0.1:2812/; proxy_set_header Host $host; } Requests to "/monit" will be redirected to "/monit/" automatically. -- Igor Sysoev http://nginx.com/support.html
on 2012-09-27 15:07
So this probably will work if I have the access_log AND include a copy of the proxy_pass directives in the nested location. The proxy_set_header, proxy_cache..., etc. would all be inherited automatically in the nested location, so I can leave those in the parent?
on 2012-09-27 15:41
Hello! On Thu, Sep 27, 2012 at 09:05:47AM -0400, AJ Weber wrote: > So this probably will work if I have the access_log AND include a > copy of the proxy_pass directives in the nested location. The > proxy_set_header, proxy_cache..., etc. would all be inherited > automatically in the nested location, so I can leave those in the > parent? Yes. You actually can leave those on server or even http level, and these directives will be inherited from there as well. > >> > >> } > >Not exactly. Each location is expected to have it's own "do > >In the above config snippet you have to duplicate proxy_pass into > >location /site/search. > > > > _______________________________________________ > nginx mailing list > nginx@nginx.org > http://mailman.nginx.org/mailman/listinfo/nginx -- Maxim Dounin http://nginx.com/support.html
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.