您的位置:首页 > 运维架构 > Nginx

#180304Nginx出现403 forbidden的问题

2018-03-04 23:10 323 查看
出现问题

[root@localhost ~]# curl -uuser:123 -x127.0.0.1:80 test.com
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.8.0</center>
</body>
</html>

查auth_basic_user_file

[root@localhost ~]# vi /usr/local/nginx/conf/vhost/test.com.conf
1 server
2 {
3     listen 80;
4     server_name test.com;
5     index index.html index.htm index.php;
6     root /data/wwwroot/test.com;
7
8     location /
9     {
10         auth_basic    "Auth";
11         auth_basic_user_file    /usr/local/nginx/conf/htpasswd;
12     }
13 }


auth_basic_user_file指定的目录/usr/local/nginx/conf/htpasswd

查命令历史
[root@localhost ~]# htpasswd -c -m /data/.htpasswd user
New password:
Re-type new password:
Adding password for user user

解决方案

[root@localhost ~]# rm -f /data/.htpasswd
[root@localhost ~]# htpasswd -c /usr/local/nginx/conf/htpasswd user
New password:
Re-type new password:
Adding password for user user
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
[root@localhost ~]# curl -uuser:123 -x127.0.0.1:80 test.com
test.com
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: