Welcome! Log In Create A New Profile

Advanced

Re: Block certain extensions preferably across virtual hosts

November 08, 2010 06:24AM
On Mon, Nov 08, 2010 at 03:36:04AM -0500, kosh wrote:

> I have been working on converting from apache to nginx and I have a
> rule
>
> RewriteRule \.(asp|aspx|php|jsp)$ - [F,L]
>
> to block all of those. What would be the best way to convert that to
> nginx and is there a way to do it in one place so that all
> virtualhosts share it?

Place this as the first location of virtual host:

location ~ \.(asp|aspx|php|jsp)$ {
return 403;
}

You may also include it as a file.

> If I could put that in one place so it applies to everything I serve
> with nginx it would be much easier to add other things to it over time.
> Mostly I want to completely block many extensions since it makes
> analyzing errors much simpler.

This is common mistake that such single place makes administration easier.
Suppose, eventually you do not need to block .php in some new site.
What will you do ?


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Block certain extensions preferably across virtual hosts

kosh November 08, 2010 03:36AM

Re: Block certain extensions preferably across virtual hosts

Igor Sysoev November 08, 2010 06:24AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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