Javascript 密码保护网站
我正试图从一个ip地址对我的网站进行密码保护Javascript 密码保护网站,javascript,apache,.htaccess,passwords,ip,Javascript,Apache,.htaccess,Passwords,Ip,我正试图从一个ip地址对我的网站进行密码保护我只想限制ip访问我的网站,但如果他们有密码,仍然允许他们访问 AuthType Basic AuthName "Login" AuthUserFile /path/to/.htpasswd Require valid-user Order deny,allow Deny from all Allow from 127.0.0.1 Satisfy any NGINX: location / { satisfy any; allow
我只想限制ip访问我的网站,但如果他们有密码,仍然允许他们访问
AuthType Basic
AuthName "Login"
AuthUserFile /path/to/.htpasswd
Require valid-user
Order deny,allow
Deny from all
Allow from 127.0.0.1
Satisfy any
NGINX:
location / {
satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Login";
auth_basic_user_file /path/to/.htpasswd;
}
将这2个文件保存在根目录中- .htaccess文件
AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/the/directory/you/are/trying/to/protect/.htpasswd
require valid-user
rohan:ra8i3s2YJemdM
.htpasswd文件
AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/the/directory/you/are/trying/to/protect/.htpasswd
require valid-user
rohan:ra8i3s2YJemdM
注意:每行一个用户名和密码,用冒号分隔。请注意,密码是加密的。您将需要使用一个特殊的工具以这种方式加密您的密码(MD5)。你可以在这里查看David Walsh的工具
您尝试了什么?peter?是.htpasswd,但它对.htpasswd不起作用。此网站是否有效?通常,是的!下次,在serverfault.com上发布您的答案,或者使用apache和htpasswd标记。Javascript和HTML不合适。:)我想要一个ip来获取消息并允许其他人访问它。上面的代码不允许我将其关闭
AuthType Basic AuthName“Login”AuthUserFile/path/.htpasswd需要有效的用户订单拒绝,从1.1.1.1允许从所有满足任何
Yes。我从ip上的孩子那里收到垃圾邮件。但我也从那个ip工作,所以我需要访问它