• nginx passwd (http://www.voidcn.com/article/p-suebfyqy-nx.html)


    操作系统CentOS 7.2

    nignx 1.10.1

    首先我们用Nginx提供HTTP的Basic Auth功能,配置了需要输入的用户名和密码,才能访问网站。

    我们使用htpasswd来生成密码信息,就先要安装httpd-tools,因在httpd-tools中包含了htpasswd命令

    我们要用在httpd-tools中htpasswd命令,来设置帐号密码

    一般安装了httpd都会有。若没有就yum install -y httpd-tools安装一下

    查看本地服务器是否安装了httpd-tools,

    $ rpm -qa | grep httpd-tools
    httpd-tools-2.4.6-45.el7.centos.4.x86_64

    接下来就创建帐号密码

    $ htpasswd -c /data0/work/nginx/passwd.db test
    New password: 
    Re-type new password: 
    Adding password for user test

    查看是否创建成功 

    $ cat  /data0/work/nginx/passwd.db
    test:$apr1$QroBUTZr$UNtXwv5nS3/jtvTCIw96h/

    发现帐号已存在,且为加密非明文密码

    那我们就在nginx配置档里进行添加设定了

    $ vim /data0/work/nginx/conf/nginx.conf
    server {
            listen  80 ;
            server_name test.xxx.com;
            charset utf-8;
            auth_basic "secrect";   ##加
            auth_basic_user_file /data0/work/nginx/passwd.db;  ##加
    location / {
            root /data0/work/nginx/html/;
            index index.html;
            ##限定可访问网站的ip
            allow  39.28.0.0/16;
            allow  47.29.0.0/16;
            allow  120.83.0.0/16;
            allow  202.6.0.0/16;
            deny all;
            }
    }
  • 相关阅读:
    hdu 1253
    poj 2531 Network Saboteur
    rwkj 1501 数据结构:图的DFS遍历
    rwkj 1306 素数========拓展
    nyist 91 阶乘之和
    nyist 65 另一种阶乘问题
    nyist 31 5个数求最值
    nyist 22 素数求和
    向量 vector
    字符串 统计 ,删除,连接,变换
  • 原文地址:https://www.cnblogs.com/agang-php/p/11578131.html
Copyright © 2020-2023  润新知