block access to a file !!

torajx nginx-forum at nginx.us
Wed Jun 6 13:22:50 UTC 2012


Hi,
it must be a piece of cake but i can not find a soloution...

the problem is " location admin.php". you can check it below...


i just want to allow access to admin.php to some ip address and deny
others.



if i remove allow line from it it deny all; but when I add allow line it
dont work ..
please help me...
I tried too many syntax but no success.
i even add root and index to this location but browser prompt to
download my php file..

please help



here 's my server section of config...very simple
server {
        listen       80;
        server_tokens off;
        server_name  www.mysite.com;
        access_log  /var/log/nginx/mysite.log;
        error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;


        location / {
           root /usr/share/nginx/www;
           index  index.php;
           client_max_body_size 8m;
           client_body_buffer_size 256k;
        }
       location = /50x.html {
           root /usr/share/nginx/html;
        }
        location = /404.html {
           root /usr/share/nginx/html;
        }
        location ~ /\.ht {
            deny  all;
        }
        location ~ \.php$ {
            root /usr/share/nginx/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME 
$document_root$fastcgi_script_name;
            include       fastcgi_params;
            set $ssl off;
            if ($ssl_protocol != "" ) {
               set $ssl on;
            }
            fastcgi_param   HTTPS                   $ssl;
        }

        location ~ admin.php {
             allow 217.66.196.193;
             deny all;
         }

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



More information about the nginx mailing list