Nginx使用httpd设置gitbook密码
安装nginx
yum -y install nginx
配置代理
[root@test ]# cat /etc/nginx/conf.d/test.conf
server {
# 监听用户访问的端口 默认是80端口
listen 80;
# server_name 服务名称 浏览器的访问域名
server_name xxx.xxx.com;
auth_basic “pleas you password”; # nginx 认证用户和密码
auth_basic_user_file /etc/nginx/conf.d/htpasswd.user; # nginx认证文件目录 能够随意指定
#配置反向代理的实现 / 拦截所有的用户请求
location / {
root html/blog; #根 静态文件目录
index index.html index.htm;
proxy_pass http://127.0.0.1:8081;
}
}
安装httpd
yum -y install httpd
htpasswd -bc htpasswd.user admin(用户) 123456(密码)
看到了 htpasswd.user 文件即可
重载nginx
nginx -s reload
再进行访问xxx.xxx.com就需要密码登入了