Hidden Locations

Matthieu Tourne matthieu.tourne at gmail.com
Wed Jun 9 02:10:44 MSD 2010


Hi,

I wanted to use internal locations to issue subrequests and internal
redirects to services, but avoid returning a 404 instantly if an
internal url is requested.

I don't have control over the websites we're proxying, so we could
potentially clobber somebody's url with our internal locations, and
named locations were too limited for this purpose (no query string,
for example).

The only way I found to do that is :

location / {
   proxy_pass <origin>;
}

location /my_hidden_service {
   internal;
   # do stuffs
   error_page 404 = /$uri;
}

This wouldn't return 404, if <origin> has a valid url called /my_hidden_service.

But I thought that this wasn't ideal, so I wrote this quick and dirty
patch to provide the keyword "hidden", instead of "internal".
hidden sets the internal flag (so they shouldn't be used in
combination), and also a hidden flag, so when sending a request to
/my_hidden_service, <origin>/my_hidden_service would be requested, and
only internal requests would see /my_hidden_service.

example :

location /my_hidden_service {
   hidden;
   # do stuffs
}

This patch was made against nginx-0.8.40, and wasn't thoroughly
tested, so if you find bugs, or think it's not a good idea to try to
do that, let me know.

Thank you,

Matthieu.

-- 
Matthieu Tourne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hidden_location.patch
Type: application/octet-stream
Size: 5175 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx/attachments/20100608/58a6e02c/attachment-0001.obj>


More information about the nginx mailing list