【发布时间】:2022-06-23 18:31:45
【问题描述】:
我有一个 wordpress 网站,配置如下:
ian@ianhobson:/etc/nginx/sites-enabled$ cat thecoachmasternetwork
# Statements for thecoachmasternetwork.com
#
# rewrites of http to https at bottom of file
server {
server_name thecoachmasternetwork.com www.thecoachmasternetwork.com;
listen 80;
fastcgi_read_timeout 300;
root /var/www/thecoachmasternetwork/htsecure;
index index.php;
fastcgi_index index.php;
access_log /var/log/nginx/thecoachmasternetwork.access.log;
# error_log /var/log/nginx/error.log;
#
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ \.user\.ini$ {
deny all;
}
# disallow hot linking to images
location ~ .(gif|png|jpg|jpeg)$ {
valid_referers none blocked thecoachmasternetwork.com www.thecoachmasternetwork.com;
if ($invalid_referer) {
return 403;
}
}
# serve static files that exist
location / {
try_files $uri $uri/ /index.php?$args;
}
# send .php files to fastcgi if file exists
location ~ \.php$ {
# Zero-day exploit defence - http://forum.nginx.org/read.php?2,88845,page=3
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root@fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
# redirects from http -> https
#server {
# if ($host = www.thecoachmasternetwork.com) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# if ($host = thecoachmasternetwork.com) {
# return 301 https://$host$request_uri;
# } # managed by Certbot
# server_name thecoachmasternetwork.com www.thecoachmasternetwork.com;
# listen 80;
# return 404; # managed by Certbot
#}
ian@ianhobson:/etc/nginx/sites-enabled$
我找不到重写或返回 301。
但是,当我请求根目录或请求 /index.php 时,访问日志显示 301 重定向到我服务器上的另一个站点。这不是 default_site,也不是第一个站点。在包含启用站点/*之前,这些已在 nginx.conf 中设置。但是仅在端口 80 上。
我怀疑是 certbot 的证书有问题,(这就是我将它切换到端口 80 的原因,所以我可以重新启动它们)。重定向到的站点在 https 上,并且看起来很好。
其他可能有用的信息。 /license.txt 已正确提供。包含
error.log 中没有任何内容。
那么发生了什么?
【问题讨论】: