Wordpress 包括允许ip地址到特定位置的列表
我想让我的wordpress管理员目录/文件只能从我的IP白名单访问 我希望该列表位于其他conf文件中,因为该列表有200多个IP 这是我的default.conf。我使用docker编写Wordpress 包括允许ip地址到特定位置的列表,wordpress,nginx,docker-compose,Wordpress,Nginx,Docker Compose,我想让我的wordpress管理员目录/文件只能从我的IP白名单访问 我希望该列表位于其他conf文件中,因为该列表有200多个IP 这是我的default.conf。我使用docker编写 server { listen 80; server_name 127.0.0.1; root /var/www/html; index index.php; access_log /var/log/nginx/access.log; error_log
server {
listen 80;
server_name 127.0.0.1;
root /var/www/html;
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location ~* /wp-login\.php|/wp-admin/((?!admin-ajax\.php).)*$ {
include /etc/nginx/conf.d/allowip.conf;
deny all;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
结果。。。
我在白名单中,当我访问mysite.com/wp-admin时,我的浏览器会下载实际的php文件
另外,我刚刚意识到,无论您是否“包括”allowip.conf,allowip.conf中的设置都是活动的
我的问题
如何将单独文件中的白名单应用于特定目录 试试这个
server {
listen 80;
server_name 127.0.0.1;
root /var/www/html;
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location ~* /wp-login\.php|/wp-admin/((?!admin-ajax\.php).)*$ {
include /etc/nginx/conf.d/allowip.conf;
deny all;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
谢谢,艾哈迈德。根据您的代码,我更改了位置=/wp-login.php,现在可以按需要工作了。我希望这能保护行政区。