sudo apt-get install apache2-utils
- 添加用户名密码
htpasswd -c /etc/nginx/.htpasswd username
- 配置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;
}
}
- 重启nginx
nginx -t
nginx -s reload