1、安装nginx
apt-get update apt-get install -y nginx
2、安装认证工具
apt-get install -y apache2-utils
3、配置认证账密
htpasswd -c /etc/nginx/.htpasswd your_username
4、配置nginx
vim /etc/nginx/nginx.conf
server { listen 80; server_name your_domain_name location / { auth_basic "Restricted Content"; auth_basic_user_file /etc/nginx/.htpasswd; try_files $uri $uri/ /index.html; } }
5、重启nginx
service nginx restart
标签:get,etc,用户,apt,认证,nginx,htpasswd From: https://www.cnblogs.com/linjiangCN/p/17817992.html