Wordpress HTTPS 模式奇怪的行为

问题描述

我在另一个 Nginx 后面的 nginx+fpm(端口 80)上运行 Wordpress,并设置了 SSL 等。 我有一些正确做这件事的背景,Wordpress 工作正常,可以提供站点,可以进入 wp-admin 等。但是,我偶然发现 WP 的“index.php”不支持某些人的 HTTPS=on 模式原因。

测试台: Wordpress 设置为通过代理后的 IP 10.130.0.4 的 https://example.com/info/ URL 传送页面。

1.

# curl -I -H "Host: example.com" -H "X-Forwarded-Proto: https" http://10.130.0.4/wp-login.php
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Wed,27 Jan 2021 18:29:27 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Wed,11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache,must-revalidate,max-age=0
Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/info/; secure
Set-Cookie: wordpress_test_cookie=WP+Cookie+check; path=/; secure
X-Frame-Options: SAMEORIGIN
# curl -I -H "Host: example.com" -H "X-Forwarded-Proto: https" http://10.130.0.4/info/
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Wed,27 Jan 2021 18:32:13 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Link: <https://example.com/info/wp-json/>; rel="https://api.w.org/"
# curl -I -H "Host: example.com" -H "X-Forwarded-Proto: https" http://10.130.0.4/
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Wed,27 Jan 2021 18:35:52 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Link: <https://example.com/info/wp-json/>; rel="https://api.w.org/"

让我几乎把头撞在桌子上的数字 4 是:

# curl -I -H "Host: example.com" -H "X-Forwarded-Proto: https" http://10.130.0.4/index.php
HTTP/1.1 301 Moved Permanently
Server: nginx/1.18.0 (Ubuntu)
Date: Wed,27 Jan 2021 18:39:21 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Redirect-By: WordPress
Location: https://example.com/

Nginx 是使用最广泛的 gist 设置的:

        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 ~ \.php$ {
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
            include fastcgi_params;
            fastcgi_intercept_errors on;
            fastcgi_pass php;
            #The following parameter can be also included in fastcgi_params file
            fastcgi_param  REQUEST_SCHEME     https;
            fastcgi_param  HTTPS              on;
            fastcgi_param  HTTP_X_FORWARDED_PROTO https;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

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

如果我在这里遗漏了任何明显的内容,请指出。 同样,WP 工作正常,但 AIOSEO 插件试图通过“http://10.130.0.4/index.php?aioseo_robots_path=root”传送 robots.txt 并被重定向到 https://example.com,这是不同的(静态)网站。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...