在WordPress上强制SSL Nginx时重定向循环

时间:2016-01-15 00:26:20

标签: php wordpress ssl nginx

我正在使用安装在运行Nginx的服务器上的pizzli.info。我试图在所有页面上强制使用ssl,但是继续遇到一个让我疯狂的重定向循环。我已经尝试查看关于这个问题的每一条信息,我找不到运气。这是我的配置文件。

    server{
listen 443;
ssl on;
 ssl_certificate /etc/ssl/pizzli_info.crt;
        ssl_certificate_key /etc/ssl/pizzli.info.key; 
         proxy_set_header X-Forwarded-Proto https;
              proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header  Host $host;
              proxy_set_header  X-Url-Scheme $scheme;
              proxy_redirect    off;
              proxy_max_temp_file_size 0;
        server_name pizzli.info;
    root /usr/share/nginx/pizzli.info;
        index index.php index.html index.htm;
            location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        allow ::1;
        deny all;

    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    proxy_set_header        X-Forwarded-Proto $scheme;
        root /usr/share/nginx/pizzli.info;
    }

    # pass the PHP scripts to PHP-FPM server listening on 127.0.0.1:9000
    location ~ \.(hh|php)$ {
    proxy_set_header        X-Forwarded-Proto $scheme;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    # deny access to .htaccess files, if Apache’s document root
    # concurs with nginx’s one
    #
   # location ~ /\.ht {
    #    deny all;
   # }
   include global/restrictions.conf;

            include global/wordpress.conf;
            location ~* \.html$ {
            proxy_set_header        X-Forwarded-Proto $scheme;
  expires -1;
}

location ~* \.(css|js|gif|jpe?g|png)$ {
proxy_set_header        X-Forwarded-Proto $scheme;
  expires 168h;
  add_header Pragma public;
  add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

        }


        server {
    listen 80 default;
    server_name pizzli.info;
    rewrite ^ https://pizzli.info$request_uri? permanent;
         proxy_set_header X-Forwarded-Proto https;
              proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header  Host $host;
              proxy_set_header  X-Url-Scheme $scheme;
              proxy_redirect    off;
              proxy_max_temp_file_size 0;
    }

0 个答案:

没有答案