【发布时间】:2019-10-10 06:17:24
【问题描述】:
我想让我的 wordpress 管理目录/文件只能从我的 IP 白名单中访问。
我希望该列表位于其他 conf 文件中,因为该列表有超过 200 个 IP。
这是我的 default.conf。我使用 docker-compose。
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 中的设置都是有效的。
我的问题
如何将单独文件中的白名单应用到某个目录?
【问题讨论】:
标签: wordpress nginx docker-compose