Welcome! Log In Create A New Profile

Advanced

Hidden Locations

All files from this thread

File Name File Size   Posted by Date  
hidden_location.patch 5.1 KB open | download Matthieu Tourne 06/08/2010 Read message
Matthieu Tourne
June 08, 2010 06:14PM
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
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Attachments:
open | download - hidden_location.patch (5.1 KB)
Subject Author Posted

Hidden Locations Attachments

Matthieu Tourne June 08, 2010 06:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 278
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