# Hidden Locations

**URL:** <https://www.ruby-forum.com/t/hidden-locations/189858>\
**Category:** NGINX\
**Created:** [June 9, 2010, 12:12am UTC](https://www.ruby-forum.com/t/hidden-locations/189858 "2010-06-09T00:12:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthieu\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Matthieu\_T](https://www.ruby-forum.com/u/Matthieu_T)\
**Post date:** [June 9, 2010, 12:12am UTC](https://www.ruby-forum.com/t/hidden-locations/189858/1 "2010-06-09T00:12:04Z")

</div>

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 ;  
}

location /my\_hidden\_service {  
internal;

# do stuffs

error\_page 404 = /$uri;  
}

This wouldn’t return 404, if 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, /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.
