Nginx配置无限循环(将HTTP重定向到HTTPS)

时间:2015-02-24 12:32:23

标签: redirect ssl nginx https

我有点卡住了。我在Nginx上设置了一个新的JTL-Shop3安装。但每当我致电https://www.domain.tld/时,它就会变成http://www.domain.tld/而反过来并最终显示错误,因为网页会在循环中重定向。

这是我的非SSL SSL的nginx配置

    # redirect non www to www
    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name trendboxx.eu www.trendboxx.eu;

    return 301 https://www.trendboxx.eu$request_uri;
    }

这里是SSL vhost的配置

   server {
    listen 443 ssl;
    ssl on;

    ssl_certificate /srv/www/trendboxx.eu/certificates/www.trendboxx.eu.crt;
    ssl_certificate_key /srv/www/trendboxx.eu/certificates/www.trendboxx.eu.key;

    server_name www.trendboxx.eu; 

    access_log   /srv/www/trendboxx.eu/logfiles/nginx.access.log;
    error_log    /srv/www/trendboxx.eu/logfiles/nginx.error.log;

    root /srv/www/trendboxx.eu/public_html;

    index index.php;

    location / {
            # try file => folder => JTL-Shop3 Search
            try_files $uri $uri/ /index.php?q=$uri$args;
    }

    # error pages
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/html;
    }

    # JTL-Shop3 expires for static files
    location ~* \.(eot|ttf|woff|css|less)$ {
            expires max;
            add_header Access-Control-Allow-Origin *;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            log_not_found off;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            access_log off;
            log_not_found off;
    }

    # PHP handler
     location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_read_timeout 180;
            proxy_read_timeout 180;
    }


    # deny access to hidden files
    location ~ /\. {
            deny all;
    }
    }

我很感激每一个如何解决这个问题的暗示。

0 个答案:

没有答案
相关问题