我有两个网站部署了nginx/1.16.1 + php7.3-fpm。
这是配置文件
网站 1:
$cat web1.conf
upstream web1 {
server unix:/run/php/web1.sock;
}
server {
listen 80;
server_name web1.com www.web1.com;
return 301 https://$host$request_uri;
}
server {
server_name web1.com www.web1.com;
ssl_certificate web1/ssl.crt;
ssl_certificate_key web1/ssl.key;
include conf.d/ssl.conf;
include conf.d/security.conf;
include conf.d/general.conf;
index index.php;
root /home/user0001/web1;
location ~ \.php$ {
include conf.d/php_fastcgi.conf;
fastcgi_pass web1;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
include conf.d/wp_security.conf;
}
网站2
$cat web2.conf
upstream web2 {
server unix:/run/php/web2.sock;
}
server {
listen 80;
server_name web2.com www.web2.com;
return 301 https://$host$request_uri;
}
server {
server_name web2.com www.web2.com;
ssl_certificate web2/ssl.crt;
ssl_certificate_key web2/ssl.key;
include conf.d/ssl.conf;
include conf.d/security.conf;
include conf.d/general.conf;
index index.php;
root /home/user0001/web2;
location ~ \.php$ {
include conf.d/php_fastcgi.conf;
fastcgi_pass web2;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
include conf.d/wp_security.conf;
}
wp_security.conf
$cat wp_security.conf
location /wp-admin {
allow xxx.x.xxx.xx/32;
deny all;
error_page 403 = @wp_admin_ban;
}
location /admin {
allow xxx.x.xxx.xx/32;
deny all;
error_page 403 = @wp_admin_ban;
}
location /wp-login.php {
allow xxx.x.xxx.xx/32;
deny all;
error_page 403 = @wp_admin_ban;
}
location @wp_admin_ban {
rewrite ^(.*) $scheme://$host permanent;
}
我使用3G/4G进行测试:
- 去https://web1.com/wp-login.php它正确地重定向到 https://web1.com
- 去https://web1.com/wp-admin/它正确地重定向到https://web1.com
- 去https://web2.com/wp-login.php它仍然加载此页面。它无法正常工作
- 去https://web2.com/wp-admin/它正确地重定向到https://web1.com
有人知道原因吗?以及如何解决此问题。谢谢