Hi, I'm trying to set up the configuration described in subject. I found for example this thread http://forum.nginx.org/read.php?2,61581,61740. This is what they advice:
> 1) all requests for particular extensions and directories to be served
> 2) everything else to return 444
>
> location ~ (/?|\.html|\.jpg|\.php|\.png|\.css|\.ico|\.js|\.swf|\.gif|robots\.txt)$ {
> ...
> }
>
> location / { return 444; }
As far as I understand this configuration doesn't work. First of all "(/?)$" in the regexp above means "anything that not nessecerily ends with /", so basically it's just anything, so access to any file or directory is still allowed. It almost works in case we remove "?":
location ~ (/|\.html|\.jpg|\.php|\.png|\.css|\.ico|\.js|\.swf|\.gif|robots\.txt)$
The problem is that this regex blocks access to all directories that were specified without trailing "/": user will got 444 trying to open http://site.com/dir but not http://site.com/dir/.
Do you have any ideas how to solve this problem?
Edited 3 time(s). Last edit at 04/06/2012 10:31AM by fmyoen.