jackyjack 大佬有话说 : 2020-3-28 09:28:03
nginx配置问题求助
站点是wordpress,套了cf。如何在nginx(openresty)里面禁止cf的请求访问wp-admin页面?
nginx部分配置如下:
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
记得cf转发的请求会有cf-ray请求头,能否实现:
有这个请求头则禁止访问wp-admin,否则正常访问?
Nameless 大佬有话说 : 2020-3-28 10:11:33
都用 CF 了为什么不用它的防火墙规则
创建一条阻止规则,把最后的 IP 换成自己要登陆后台的 IP,或者删最后一个条件
(http.request.uri.path contains "/xmlrpc.php") or (http.request.uri.path contains "/wp-login.php") or (http.request.uri.path contains "/wp-admin/" and not http.request.uri.path contains "/wp-admin/admin-ajax.php" and not http.request.uri.path contains "/wp-admin/theme-editor.php" and ip.src ne 123.123.123.123)
BJY678 大佬有话说 : 2020-3-28 10:13:45
楼上大佬方案可行:lol
jackyjack 大佬有话说 : 2020-3-28 10:35:00
Nameless 大佬有话说 : 2020-3-28 10:11
都用 CF 了为什么不用它的防火墙规则
创建一条阻止规则,把最后的 IP 换成自己要登陆后台的 IP,或者删最 …
感谢,我试试
chiholam 大佬有话说 : 2020-3-28 11:05:55
技术插帖留签