太多重定向nginx + magento

时间:2017-04-04 23:49:43

标签: ubuntu nginx

我的服务器环境是ubuntu + nginx + mysql,并且有两个月的问题就像浏览Magento很长一段时间后我们得到“ www.example.com重定向你太多次”浏览器。它在一天中频繁发生(一天2-3次)。清除浏览器缓存和cookie后,它就像正常一样工作。 我们正在使用Magento 1.9.3版本。 我们最近安装了新的SSL。

希望以上信息有所帮助,有人可以帮我解决一下吗?

以下是nginx配置文件

 server {
    listen    8080;
    server_name www.example.com.au example.com.au;
    return 301 https://$server_name$request_uri;
    root        /var/www/vhosts/www.example.com.au;

 index index.html index.php;
    port_in_redirect off;   
    access_log /var/log/nginx/www.example.com.au-access_log;
    error_log /var/log/nginx/www.example.com.au-error_log;

    location / {
        try_files $uri $uri/ @handler;
        expires 30d;
        proxy_connect_timeout 180s;
     proxy_read_timeout 180s;

    }
    location /newmod/{
try_files $uri $uri/newmod/ @handler1;
expires 0d;
    }           

    location /newmod/app/                       { deny all; }
    location /newmod/includes/                  { deny all; }
    location /newmod/lib/                       { deny all; }
    location /newmod/media/downloadable/        { deny all; }
    location /newmod/pkginfo/                   { deny all; }
    location /newmod/report/config.xml          { deny all; }
    location /newmod/var/                       { deny all; }
    location /xmlrpc.php                  { deny all; }
    location /newmod/downloader/                {deny all;}
    location /newmod/dev/                       {deny all; }
    location /newmod/var/export/ {
        auth_basic              "Restricted";
        auth_basic_user_file    htpasswd;
        autoindex               on;
    }
    location  /. {
        return 404;
    }

    location @handler {
        rewrite / /index.php;
        rewrite /sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite /([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
    }
location @handler1{
rewrite /newmod /newmod/index.php;
}

location ~ .php/ {
        rewrite ^(.*.php)/ $1 last;
    }

    location ~ \.php$ {
        try_files $uri =404;
        expires off;
        fastcgi_read_timeout 2400s;
        fastcgi_index index.php;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
    rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
    rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;

    location /lib/minify/ {
        allow all;
    }
    gzip on;
    #gzip_comp_level 9;
    gzip_min_length  1000;
    gzip_proxied any;
    gzip_types       text/plain application/xml text/html text/css text/js application/x-javascript;
}

1 个答案:

答案 0 :(得分:0)

由于2个原因,发生了许多重定向。 1)您的magento Web URL错误。 2)yournginx配置错误。 我假设你在使用两个端口80和443。 现在你必须改变2件事 1)magento web urls。(如果需要) 2)nginx配置。

server { listen 80;   server_name www.example.com;  return 301 https://www.example.com$request_uri;}`server {listen 443 ssl;  root /var/www/html/www.example.com;index index.php index.html index.htm;server_name www.example.com;resolver 8.8.4.4 8.8.8.8 valid=300s;resolver_timeout 10s;ssl_certificate /etc/nginx/ssl/nginx.crt;ssl_certificate_key /etc/nginx/ssl/nginx.key;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;#ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;#ssl_prefer_server_ciphers on;ssl_session_cache shared:SSL:10m;ssl_session_timeout 10m;.......}`

把你的其他代码代替..... 希望你得到答案