How to use Nginx to restrict access to everyfiles to 127.0.0.1, except the php files in /

carlg nginx-forum at nginx.us
Thu Nov 13 08:33:03 UTC 2014


Hi,

It works, but i am still able to access the php files inside the restricted
directories.  I tried with :

location /myfolder/(.+)\.php$ {
deny all;
}

But this doesn't work!

Also, i cannot make this method work nice with our clean url's.  We are
using : 

location / {
		#try_files $uri $uri/ /index.php;
		#try_files $uri/ $uri /index.php?$query_string;
                include /etc/nginx/naxsi.rules;
                try_files $uri $uri.html $uri/ @extensionless-php;

	}

	location @extensionless-php {
    		rewrite ^(.*)$ $1.php last;
	allow all;	
}

thank you in advance for your help,

Carl

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,254785,254799#msg-254799



More information about the nginx mailing list