使用.htaccess限制从网站中排除特定IP

问题描述 投票:0回答:1

我想授予对托管网站(nginx)的公共访问权限,并排除访问它的特定IP地址范围(123.456)。

简单地说:IP-Range 123.456的每次访问都应该通过Promname for Username / Password来限制。多数民众赞成我想拥有的东西。

在这里我的.htaccess。

AuthType Basic
AuthName "Go away!"
AuthUserFile /home/www/path-to-my/.htpasswd
Require valid-user
Order Allow,Deny
Allow from all
Deny from 123.456
Satisfy any

我使用它时得到的结果:

  • 公共访问成功
  • 从排除的IP范围=超时访问
.htaccess nginx webserver access restriction
1个回答
0
投票

就像我所知道的那样.htaccess文件仅适用于apache web服务器,而不适用于nginx。

您需要使用a converter转换规则或自行完成。

在你的情况下:

# nginx configuration
auth_basic "Go away!";
auth_basic_user_file /home/www/path-to-my/.htpasswd;
deny 123.456;
satisfy any;

配置指令非常相似,但它们是不同的。

© www.soinside.com 2019 - 2024. All rights reserved.