#180304 Nginx has the problem of 403 forbidden

problem appear

[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 }

The directory specified by 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

solution

[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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325233691&siteId=291194637