Hello,
http://nginx.org/en/docs/http/request_processing.html
Because in this case you need to place your rule in server block if you
would like to be valid for all custom defined locations in your config
For example:
server
{
listen 80;
if ($remote_addr ~ '192.168.1.25')
{
return 403;
}
location /
{
...
}
location ~ \.php$
{
...
}
}
On 23.05.2013 23:11 ч., wishmaster wrote:
Hi,
I use opencart with nginx+php-fpm. Sometimes it is necessary to redirect all clients,
except admin (190.212.201.0/24), to "Service unavailable" page which is simple
index.html file with logo, background image and some text, located in /unav directory.
Below some of nginx.conf
location / {
if ($remote_addr !~ '190\.212\.201\.[0-9]{0,3}') {
rewrite ^/(.*)$ /unav/$1 break;
return 403;
}
try_files $uri $uri/ @opencart;
}
location ^~ /unav {
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
[...skipped...]
location ~ \.php$ {
try_files $uri =404;
fastcgi_read_timeout 60s;
fastcgi_send_timeout 60s;
include myphp-fpm.conf;
}
Problem is in rewriting.
This rule
rewrite ^/(.*)$ /unav/$1 break;
rewrite ONLY http://mysite.com/ request but in case http://mysite.com/index.php
rewrite is none and request processed by location ~ \.php$ rule. Why??
Thanks!
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx