Welcome! Log In Create A New Profile

Advanced

ERR_TOO_MANY_REDIRECTS при условии

Posted by dmydry 
ERR_TOO_MANY_REDIRECTS при условии
May 30, 2011 07:24AM
Привет всем. Такая странная проблема:

Вот конфиг.

server {
listen domain.com:80;
server_name *.domain.com domain.com;

root /var/www/domain;

if ( $scheme = 'http' ) {
rewrite ^/(.*) https://domain.com/$1;
}

if ($host = 'www.domain.com' ) {
rewrite ^/(.*)$ https://domain.com/$1 permanent;
}
}
geo $country {
include geo.conf;
}

server {

if ($host = 'www.domain.com' ) {
rewrite ^/(.*)$ https://domain.com/$1 permanent;
}

listen domain.com:443;
server_name *.domain.com www.domain.com domain.com;

root /var/www/domain;

access_log /var/log/nginx/access-ssl.log;
error_log /var/log/nginx/error-ssl.log;

ssl on;
ssl_certificate /etc/ssl/certs/domain.com.crt;
ssl_certificate_key /etc/ssl/certs/domain.com.key;

ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;

location / {

root /var/www/domain;
index index.html index.php index.htm;

if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}

location ~*\.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ {
root /var/www/domain;
}

location ~* ^\/forum\/.+\.php$ {
if ($country = UA) {
rewrite ^(.*)$ https://domain.com/ddos.html;
}
if ($country = RU) {
return 403;
rewrite ^(.*)$ https://domain.com/ddos.html;
}

root /var/www/domain;
index index.php index.html index.htm;


fastcgi_pass localhost:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/domain$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_connect_timeout 75;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
include fastcgi_params;
}


location ~ \.php$ {

fastcgi_pass localhost:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/domain$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_connect_timeout 75;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
include fastcgi_params;
}

}


При таком конфиге отлично выполняется условие редиректа
if ($country = UA) {
rewrite ^(.*)$ https://domain.com/ddos.html;
}
if ($country = RU) {
return 403;
rewrite ^(.*)$ https://domain.com/ddos.html;
}

Но, если вставить такое же уловие в location /
location / {
root /var/www/domain;
index index.html index.php index.htm;
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
if ($country = UA) {
rewrite ^(.*)$ https://domain.com/ddos.html;
}
if ($country = RU) {
rewrite ^(.*)$ https://domain.com/ddos.html;
}
}

То образуется ошибка ERR_TOO_MANY_REDIRECTS.

Подскажите, как сделать ограничение по странам для ВСЕГО сайта, а не только для форума?

Спасибо
Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 214
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready