Translating apache config to nginx

Francis Daly francis at
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 /, 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 /,
it should be allowed; if it is not like / 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.

Francis Daly        francis at

More information about the nginx mailing list