In order to facilitate reading information, such as technical articles, audio, and video, I Docker
set up Nginx
After friends and colleagues know more and more people, they feel that it is necessary to make some security restrictions.
- install software
apt install apache2-utils
- Create a directory
mkdir /etc/apache
- Create an account
htpasswd -c /etc/apache/htpasswd admin
Next follow the prompts to set a password
New password:
Re-type new password:
- modify
Nginx
configuration
server{
listen 80;
server_name *.*.*.*;
root /usr/share/nginx/html;
location /doc {
auth_basic "账号登录"; # 开启认证
auth_basic_user_file /etc/apache/htpasswd; # 上面指定的密码文件
alias /usr/share/nginx/html;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
charset utf-8,gbk;
}
}
- Restart
Nginx
the container
docker restart nginx