有时侯部分网站不想被别人看到,须要进行加密访问,此时对nginx进行简单配置便可
location / { root html; index index.html index.htm index index.jpg; auth_basic 'Restricted'; # 认证名称,随意填写 auth_basic_user_file /htpasswd/passwd.db; # 认证的密码文件,须要生产。 }
htpasswd -c /htpasswd/passwd.db test chmod 777 /htpasswd/passwd.db test /usr/local/nginx/sbin -s relaod