Portal Home > Knowledgebase > Articles Database > How to use Nginx to restrict access to everyfiles, except the php files in /


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




Posted by martin33, 11-11-2014, 07:25 PM
HI, I want to configure our nginx to be a little more paranoid concerning file access. Right now, i am using rules like : location /includes { allow 127.0.0.1; deny all; } ... but i need to repeat this kind of rules for every folders, and then restrict access to the php files inside. So our rules file is too long, complicated and getting very messy. The php files a visitor require to be able to reach directly are in / (like clientarea.php, login.php, etc..) I would like to restrict every other files to 127.0.0.1, and then add some rules to allow all trafic where required (example in the .tpl file of the cPanel module). But i cannot figure out how i can achieve this with nginx. Any help will be very appreciated, and may help may others i am sure to be more secure Thank you, Martin

Posted by helix247, 11-11-2014, 10:46 PM
Are you trying to restrict access to files to a single IP adress? Can you just use your IP address instead of localhost?

Posted by martin33, 11-12-2014, 03:56 AM
Hi, no, it has to be 127.0.0.1. only the php files in / need to be avalailble to everyone and the rest 127.0.0.1

Posted by helix247, 11-12-2014, 08:45 AM
Very well, could you move all files except for the ones that need 127.0.0.1 into a sub-domain with a separate .conf and location restriction or vice versa?

Posted by TempleNode, 11-12-2014, 08:56 AM
I didn't test it but should be something like that.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Help CHMOD (Views: 717)
Route over the gateway (Views: 810)


Language:

LoadingRetrieving latest tweet...

Back to Top Copyright © 2018 DC International LLC. - All Rights Reserved.