Ubuntu 下 使用nginx设置用户名密码访问
文章目录
1.下载工具
sudo apt-get install apache2-utils- 添加用户名密码
htpasswd -c /etc/nginx/.htpasswd username输入密码,提示如下:
New password:
Re-type new password:
Adding password for user exampleuserhtpaswd的.htpasswd文件格式如下:
login:password
注意:htpasswd需要对nginx运行用户可访问
添加配置到NGINX配置
如:
server {
listen 80;
server_name home.moosrtc.com;
location / {
root /codes/index;
index index.htm index.html;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}重启
sudo service nginx restart

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论