<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>block access to a file !!</title>
<description>Hi,
it must be a piece of cake but i can not find a soloution...

the problem is &amp;quot; location admin.php&amp;quot;. 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 != &amp;quot;&amp;quot; ) {
set $ssl on;
}
fastcgi_param HTTPS $ssl;
}

location ~ admin.php {
allow 217.66.196.193;
deny all;
}</description><link>http://forum.nginx.org/read.php?2,227281,227281#msg-227281</link><lastBuildDate>Sun, 19 May 2013 19:24:25 -0400</lastBuildDate>
<generator>Phorum 5.2.16</generator>
<item>
<guid>http://forum.nginx.org/read.php?2,227281,227400#msg-227400</guid>
<title>Re: block access to a file !!</title><link>http://forum.nginx.org/read.php?2,227281,227400#msg-227400</link><description><![CDATA[Thank you ! it worked great...]]></description>
<dc:creator>torajx</dc:creator>
<category>Nginx Mailing List - English</category><pubDate>Sun, 10 Jun 2012 10:53:30 -0400</pubDate></item>
<item>
<guid>http://forum.nginx.org/read.php?2,227281,227376#msg-227376</guid>
<title>Re: block access to a file !!</title><link>http://forum.nginx.org/read.php?2,227281,227376#msg-227376</link><description><![CDATA[thank you again; i will test and inform you here...]]></description>
<dc:creator>torajx</dc:creator>
<category>Nginx Mailing List - English</category><pubDate>Sat, 09 Jun 2012 02:44:23 -0400</pubDate></item>
<item>
<guid>http://forum.nginx.org/read.php?2,227281,227286#msg-227286</guid>
<title>Re: block access to a file !!</title><link>http://forum.nginx.org/read.php?2,227281,227286#msg-227286</link><description><![CDATA[On Wed, Jun 06, 2012 at 09:50:57AM -0400, torajx wrote:<br />&gt; thank you for reply..<br />&gt; i change it to &quot;location = /admin.php &quot;<br />&gt; and move it above the &quot;location ~ \.php$ &quot;<br /><br />&quot;&quot;&quot;<br />Either use something like &quot;location = /admin.php&quot;, or maybe reorder to<br />regex locations (with ~) so they match in the order you want.<br />&quot;&quot;&quot;<br /><br />You've done both. That's ok, but unnecessary.<br /><br />&gt; it blocks other IPs but give file not found error for allowed Ips..<br />&gt;<br />&gt; the last time I added root to admin.php location the browser promot me<br />&gt; to download admin.php..<br />&gt;<br />&gt; what can I do now ?<br /><br />&quot;&quot;&quot;<br />You will (probably) want to repeat your fastcgi_pass and other fastcgi_*<br />config lines inside the new location block. One request is handled by<br />one location.<br />&quot;&quot;&quot;<br /><br />Do that.<br /><br />f<br />--<br />Francis Daly francis@daoine.org<br /><br />_______________________________________________<br />nginx mailing list<br />nginx@nginx.org<br />http://mailman.nginx.org/mailman/listinfo/nginx]]></description>
<dc:creator>Francis Daly</dc:creator>
<category>Nginx Mailing List - English</category><pubDate>Wed, 06 Jun 2012 10:32:01 -0400</pubDate></item>
<item>
<guid>http://forum.nginx.org/read.php?2,227281,227284#msg-227284</guid>
<title>Re: block access to a file !!</title><link>http://forum.nginx.org/read.php?2,227281,227284#msg-227284</link><description><![CDATA[thank you for reply..<br />i change it to &quot;location = /admin.php &quot;<br />and move it above the &quot;location ~ \.php$ &quot;<br />it blocks other IPs but give file not found error for allowed Ips..<br /><br />the last time I added root to admin.php location the browser promot me to download admin.php..<br /><br />what can I do now ?]]></description>
<dc:creator>torajx</dc:creator>
<category>Nginx Mailing List - English</category><pubDate>Wed, 06 Jun 2012 09:50:57 -0400</pubDate></item>
<item>
<guid>http://forum.nginx.org/read.php?2,227281,227283#msg-227283</guid>
<title>Re: block access to a file !!</title><link>http://forum.nginx.org/read.php?2,227281,227283#msg-227283</link><description><![CDATA[On Wed, Jun 06, 2012 at 09:22:50AM -0400, torajx wrote:<br /><br />Hi there,<br /><br />&gt; it must be a piece of cake but i can not find a soloution...<br />&gt;<br />&gt; the problem is &quot; location admin.php&quot;. you can check it below...<br /><br />No, the problem is &quot;location ~ admin.php&quot; coming after &quot;location ~<br />\.php$&quot;. The exact characters matter.<br /><br />http://nginx.org/r/location<br /><br />&gt; i just want to allow access to admin.php to some ip address and deny<br />&gt; others.<br /><br />Either use something like &quot;location = /admin.php&quot;, or maybe reorder to<br />regex locations (with ~) so they match in the order you want.<br /><br />You will (probably) want to repeat your fastcgi_pass and other fastcgi_*<br />config lines inside the new location block. One request is handled by<br />one location.<br /><br />Good luck with it,<br /><br />f<br />--<br />Francis Daly francis@daoine.org<br /><br />_______________________________________________<br />nginx mailing list<br />nginx@nginx.org<br />http://mailman.nginx.org/mailman/listinfo/nginx]]></description>
<dc:creator>Francis Daly</dc:creator>
<category>Nginx Mailing List - English</category><pubDate>Wed, 06 Jun 2012 09:42:00 -0400</pubDate></item>
<item>
<guid>http://forum.nginx.org/read.php?2,227281,227281#msg-227281</guid>
<title>block access to a file !!</title><link>http://forum.nginx.org/read.php?2,227281,227281#msg-227281</link><description><![CDATA[Hi,<br />it must be a piece of cake but i can not find a soloution...<br /><br />the problem is &quot; location admin.php&quot;. you can check it below...<br /><br /><br />i just want to allow access to admin.php to some ip address and deny others.<br /><br /><br /><br />if i remove allow line from it it deny all; but when I add allow line it dont work ..<br />please help me...<br />I tried too many syntax but no success.<br />i even add root and index to this location but browser prompt to download my php file..<br /><br />please help<br /><br /><br /><br />here 's my server section of config...very simple<br />server {<br />listen 80;<br />server_tokens off;<br />server_name www.mysite.com;<br />access_log /var/log/nginx/mysite.log;<br />error_page 404 /404.html;<br />error_page 500 502 503 504 /50x.html;<br /><br /><br />location / {<br />root /usr/share/nginx/www;<br />index index.php;<br />client_max_body_size 8m;<br />client_body_buffer_size 256k;<br />}<br />location = /50x.html {<br />root /usr/share/nginx/html;<br />}<br />location = /404.html {<br />root /usr/share/nginx/html;<br />}<br />location ~ /\.ht {<br />deny all;<br />}<br />location ~ \.php$ {<br />root /usr/share/nginx/www;<br />fastcgi_pass 127.0.0.1:9000;<br />fastcgi_index index.php;<br />fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br />include fastcgi_params;<br />set $ssl off;<br />if ($ssl_protocol != &quot;&quot; ) {<br />set $ssl on;<br />}<br />fastcgi_param HTTPS $ssl;<br />}<br /><br />location ~ admin.php {<br />allow 217.66.196.193;<br />deny all;<br />}]]></description>
<dc:creator>torajx</dc:creator>
<category>Nginx Mailing List - English</category><pubDate>Wed, 06 Jun 2012 09:22:50 -0400</pubDate></item>
</channel>
</rss>