nginx設置用戶名和密碼
yum -y install nginx
nginx部分配置文件
server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { auth_basic "elk"; auth_basic_user_file /etc/nginx/htpasswd; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
[[email protected] html]# htpasswd -cb /etc/nginx/htpasswd liuhx 123456 Adding password for user liuhx [[email protected] html]# cat /etc/nginx/htpasswd liuhx:$apr1$qoRxZ3ly$0PTCsKkfyujESjb8Twdj9/
[[email protected] html]# echo "test 加密"> /usr/share/nginx/html/index.html [[email protected]
nginx -t nginx
本文出自 “磚家博客” 博客,請務必保留此出處http://wsxxsl.blog.51cto.com/9085838/1947098
nginx設置用戶名和密碼