你好,我试图拒绝使用nginx访问我的网站的URL admin.php的外部IP。
我有一个带有example.com/admin.php的jirafeau服务器,我试图拒绝这个页面的访问,但是不工作。我是新来的,这是我的公寓:
位置/{ try_files $uri $uri/ /admin.php;拒绝所有;允许X.X/24;}
这拒绝了我的网站的所有外部ip,我只需要拒绝访问admin.php
来寻求帮助!
发布于 2022-03-15 12:47:59
NGINX短解:
您可以使用以下两种方法:
location = /admin.php {
deny all;
allow 10.0.0.0/8; }location ~* admin.php {
deny all;
allow 10.0.0.0/8; } location = /admin.php {
deny all;
allow 10.0.0.0/8; }
auth_basic "restricted area";
auth_basic_user_file /etc/nginx/htpw/.htpasswd; location = /admin.php {
auth_basic "restricted area";
auth_basic_user_file /etc/nginx/htpw/.htpasswd;提醒您,如果浏览器缓存不能直接工作(当然,如果您没有忘记重新加载nginx ),那么浏览器缓存可能会使您自己变得棘手。
参考资料:
https://serverfault.com/questions/1096181
复制相似问题