NGINX SSL太多重定向?

时间:2018-01-03 21:24:33

标签: wordpress ssl nginx

环境

  • Ubuntu 16.04
  • NGINX Light
  • WordPress的

配置

此问题的域名已更改为example.com

如果我绕过端口443,我会获得默认的NGINX登录页面,而不是我的WordPress网站。

    # SSL configuration
    server {

    # Ports to listen on, uncomment one.

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # Server name to listen for
    server_name example.com;
    server_tokens off;

    # Path to document root
    root /var/www/example.com/html;

    # Paths to certificate files
    ssl_certificate      
    /var/www/example.com/cert/example.com.crt;
    ssl_certificate_key /var/www/example.com/cert/example.key;

    # File to be used as index
    index index.html index.php;

    # SSL Security
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";


    include hhvm.conf;

    # HHVM Location PHP Setup

    location ~ .php$ {
            fastcgi_keep_conn on;
            if (!-e $request_filename) { rewrite / /index.php last; }
            expires        off;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param PHP_VALUE "error_log=/var/report/PHP.error.log";
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
    }


    # WordPress stuff
    location = /favicon.ico {
            log_not_found off;
            access_log off;
    }

    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }

    location / {
            # This is cool because no php is touched for static content.
            # include the "?$args" part so non-default permalinks doesn't     break when using query string
            try_files $uri $uri/ /index.php?$args;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }

# Write an error log
    error_log /var/log/nginx/example.com.error.log;
}

# Redirect http to https
    server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;

    server_tokens off;
}

我也尝试了这些,但结果相同。重定向噩梦

# Redirect http to https
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;

    server_tokens off;
}

# Redirect www to non-www
server {
    listen 443;
    listen [::]:443;
    server_name www.example.com;

    return 301 https://example.com$request_uri;
}

0 个答案:

没有答案