reverse proxy root folder only

Francis Daly francis at daoine.org
Sat Jan 7 10:02:27 UTC 2012


On Fri, Jan 06, 2012 at 07:17:42PM -0500, starmonche wrote:

Hi there,

> I have an nginx serverset up and I'm looking for a way to only reverse
> proxy the contents of the root folder. I'm using a location regex with a
> list of the files in root that are allowed and then a second catch-all
> location that goes nowhere but there must be an easier or cleaner way to
> do this.

Conceptually, one location{} for the things you want, plus one for all
else, *is* the easy way to do it.

(That's more or less the same as one location{} for the things you don't
want, plus one for all else.)

Arguably the cleaner way is to have one exact location{} for each thing
you want, plus one for the rest, but I guess you're not looking for that.

So: what is "the contents of the root folder"? If it is "exactly these
file names", then your current

 location ~ ^/(one|two|three)$

is correct. If it is "any request without a second /", then

 location ~ ^/[^/]*$

should work.

And if you go the other way, and have "location /" as your "this is
the root folder" block, then "all else" would be "any request with two
slashes", which could be

 location ~ /.*/

(All untested, by the way.)

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list