Welcome! Log In Create A New Profile

Advanced

Re: Sanity check of my config - is it secure?

António P. P. Almeida
May 26, 2011 04:26PM
On 26 Mai 2011 21h10 WEST, nginx-forum@nginx.us wrote:

> Thanks people
>
> So there's no way to say "If the file ISNT a jpeg/gif/css/js"
> deny. The only way is to say 'if .php' deny, 'if .txt deny' etc?
>
> I'd prefer to whitelist the files i DO want to return and block
> everything else, incase I forget something to block?
>

Try this:

location ~* /static_files_dir/(?:[^.]*)\.(?<extension>.*)$ {
if ($extension !~ (jpe?g|png|gif|ico|css|js)) {
return 444;
}
}

It's rather ugly :(

--- appa

PS: No need to use ?: in the if condition.

PPS: Note that if the filenames have dots '.' in them the above regex
will fail to capture the extension correctly. You're opening a can of
worms config wise when going down this path.

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

Sanity check of my config - is it secure?

benseb May 22, 2011 10:56AM

Re: Sanity check of my config - is it secure?

vesperto May 22, 2011 12:50PM

Re: Sanity check of my config - is it secure?

benseb May 22, 2011 01:24PM

Re: Sanity check of my config - is it secure?

Justin Cormack May 22, 2011 01:38PM

Re: Sanity check of my config - is it secure?

benseb May 22, 2011 02:37PM

Re: Sanity check of my config - is it secure?

Igor Sysoev May 27, 2011 01:40AM

Re: Sanity check of my config - is it secure?

benseb May 26, 2011 03:22PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 03:34PM

Re: Sanity check of my config - is it secure?

benseb May 26, 2011 03:36PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 03:48PM

Re: Sanity check of my config - is it secure?

benseb May 26, 2011 03:49PM

Re: Sanity check of my config - is it secure?

benseb May 26, 2011 04:10PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 04:02PM

Re: Sanity check of my config - is it secure?

vesperto May 26, 2011 04:06PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 04:20PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 04:22PM

Re: Sanity check of my config - is it secure?

benseb May 26, 2011 04:30PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 04:44PM

Re: Sanity check of my config - is it secure?

Aaron Starr May 26, 2011 05:08PM

Re: Sanity check of my config - is it secure?

benseb May 26, 2011 05:09PM

Re: Sanity check of my config - is it secure?

António P. P. Almeida May 26, 2011 04:26PM

Re: Sanity check of my config - is it secure?

Igor Sysoev May 27, 2011 01:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 124
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready