【nginx】:给nginx增加 password 配置通过简单的方式限制登陆。使用openssl 生成密码
生成密码
openssl passwd -1 -salt ‘12345678’ ##注意‘12345678’不是密码而是密码的长度
Password: ##这里输入的是密码
然后拷贝密码到:
htpasswd
修改nginx 配置
server {
listen 80;
gzip on;
server_name test.test.com;
root /data/www/test-doc;
location / {
auth_basic "Please enter your username and password";
# nginx or openresty conf:
auth_basic_user_file /usr/local/openresty/nginx/conf/htpasswd;
autoindex on;
proxy_pass http://127.0.0.1:8080;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location = /404.html {
root html;
}
}
密码格式:
用户名:openssl生成的密码