首页 > 其他 > 详细

nginx设置用户名和密码

时间:2017-07-13 15:57:20      阅读:351      评论:0      收藏:0      [点我收藏+]
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 {
        }
    }
[root@l2tp html]#  htpasswd -cb /etc/nginx/htpasswd liuhx 123456
Adding password for user liuhx
[root@l2tp html]# cat /etc/nginx/htpasswd 
liuhx:$apr1$qoRxZ3ly$0PTCsKkfyujESjb8Twdj9/
[root@l2tp html]# echo  "test 加密"> /usr/share/nginx/html/index.html 
[root@l2tp html]#
nginx -t
nginx

技术分享

技术分享


本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1947098

nginx设置用户名和密码

原文:http://wsxxsl.blog.51cto.com/9085838/1947098

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!