Translating apache config to nginx

Francis Daly francis at daoine.org
Fri Feb 21 20:25:15 UTC 2014


On Fri, Feb 21, 2014 at 07:36:20AM -0800, Grant wrote:

Hi there,

> Here is the description:
> 
> "deny access to files not containing a dot or starting with a dot in
> all locations except installer directory"

So: you want it to block /one and /two/, to allow /thr.ee, and to block /.four, yes?

> Should the following accomplish this in nginx?  It gives me 403 during
> normal operation.

That configuration seems to get the first three correct and the last
one wrong.

If you add a "/" immediately after the first ^, it seems to get all
four correct.

What is "normal operation"? If the request you make is like /thr.ee,
it should be allowed; if it is not like /thr.ee is should be blocked.

(Personally, I'm not sure why you would want that set of restrictions. But
if you want it, this is one way to get it.)

> location ~ ^(?!installer)(\.?[^\.]+)$ {
>     deny all;
> }

A more nginx-ish way would probably be to only have prefix locations at
the top level; but if what you have works for you, it's good.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list