2

I want to deny access to one specific folder (and all files inside of it) but I'd like that php files from inside my server could have access to it (and its files). Is it possible? This is what I am trying without suvccess:

location /folder/ {
    allow 1.2.3.4;  # my server IP
    deny all;
    return 404;
}
2
  • 1
    If PHP is on the same server as the files then file access has nothing to do with your webserver. Oct 9, 2011 at 10:01
  • You are so right. A simple php fileopen or include did the job. And the rule above still protect the files from being accessed inside the folder. Thank you.
    – Roger
    Oct 9, 2011 at 11:50

2 Answers 2

1

The ACLs you set up in the nginx-configuration, is for the http-requests that will be served by nginx. If PHP wants to access other files, it is not constrained by the configuration of nginx. PHP however, can be constrained by its own configuration.

Since you want to move some security to PHP, I want to note that PHP may have access to configuration files and the likes. So you should make sure that you don't allow code like this to give any useful information to an attacker:

http://my.server.acme.org/images.php?file=../../../etc/passwd
0

In the reality, this is what worked for me:

location ~ folder/ {
            allow 1.2.3.4;  #server IP
            deny all;
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .