主页无限循环 nginx 配置错误(缓存、nginx + varnish)

主页无限循环 nginx 配置错误(缓存、nginx + varnish)

主页重定向问题

Result
https://www.example.com
301 Moved Permanently
https://www.example.com/
301 Moved Permanently
https://www.example.com/
301 Moved Permanently
https://www.example.com/

>>> https://www.example.com

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 08 Mar 2020 17:12:27 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Set-Cookie: PHPSESSID=nc8ae71cti111f4886i4n88c8g; path=/
X-Powered-By:   PHP/7.4.2
Expires:    Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:  no-store, no-cache, must-revalidate
Pragma: no-cache
X-Redirect-By:  WordPress
Strict-Transport-Security:  max-age=63072000; includeSubDomains; preload
X-Frame-Options:    DENY
X-Content-Type-Options: nosniff
Location:   https://www.example.com/
X-Varnish:  275505
Age:    0
Via:    1.1 varnish (Varnish/6.0)
CF-Cache-Status:    DYNAMIC
Expect-CT:  max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Alt-Svc:    h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400
Server: cloudflare
CF-RAY: 570e2e5f387adfbb-FRA




>>> https://www.example.com/

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Sun, 08 Mar 2020 17:12:27 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Set-Cookie: PHPSESSID=phieba6dvq78s19s6mnriqlkhi; path=/
X-Powered-By:   PHP/7.4.2
Expires:    Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:  no-store, no-cache, must-revalidate
Pragma: no-cache
X-Redirect-By:  WordPress
Strict-Transport-Security:  max-age=63072000; includeSubDomains; preload
X-Frame-Options:    DENY
X-Content-Type-Options: nosniff
Location:   https://www.example.com/
X-Varnish:  275511
Age:    0
Via:    1.1 varnish (Varnish/6.0)
CF-Cache-Status:    DYNAMIC
Expect-CT:  max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Alt-Svc:    h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400
Server: cloudflare
CF-RAY: 570e2e625f301f15-FRA

这是我的 nginx 配置,我将它用于 ssl,因为我在端口 80 上有 varnish,在端口 8080 上有 apache,并且 nginx 许可 443 ssl。

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
            listen 443 ssl;
            server_name _;
index index.php index.html index.htm;
            ssl_certificate /etc/letsencrypt/live/www.sitename.com/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/www.sitename.com/privkey.pem;
            location / {
                proxy_pass http://127.0.0.1:80;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Forwarded-Port 443;
                proxy_set_header Host $host;
            }
    }
}

我的 wordpress 主页陷入无限循环。

错误信息

网站的其余部分看起来运行正常,我有 cloudflare 以及名称服务器和缓存。(我认为所有的 cookie 都乱了,因为我无法登录 wp-admin)

我已经检查过使用网站http://www.redirect-checker.org/并显示常规页面有 4 个重定向,主页有 19 个(无限循环)

知道如何修复吗?

相关内容