Laravel Forge-部署Wordpress + HTTPS导致“重定向过多”

时间:2019-09-04 22:46:02

标签: wordpress nginx laravel-forge

我的Nginx配置文件:

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.example.com/before/*;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.example.com;
    root /home/forge/www.example.com;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/www.example.com/616559/server.crt;
    ssl_certificate_key /etc/nginx/ssl/www.example.com/616559/server.key;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DO NOT REMOVE!)
    include forge-conf/www.example.com/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/www.example.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.example.com/after/*;

站点域为www.example.com 别名:example.com

有什么主意吗?

1 个答案:

答案 0 :(得分:0)

只需将解决方案发布给处于相同情况的任何人:

问题根本与发布的Nginx配置完全无关,这是正确的。 在寻找解决方案一段时间后,我意识到我有两个DNS记录(在我的Web和域托管的DNS表中)指向DNS表中的www.example.com,导致访问Web时的行为。

谢谢。