zoukankan      html  css  js  c++  java
  • nginx 配置身份验证 http_auth_basic_module

    ngx_http_auth_basic_module模块实现访问必须输入用户名和密码 正确情况向访问,这为我们一些重要资源访问增添了一道安全锁。

    语法:     auth_basic_user_file file;
    默认值:     —
    配置段:     http, server, location, limit_except

    用户密码加密方式
    http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html

    支持htpasswd等

    htpasswd安装
    yum install httpd-tools -y

    首次创建并加入
    htpasswd -c ./user_passwd admin

    会出现

    New password: 
    Re-type new password: 
    Adding password for user admin

    两次密码都正确情况下创建用户成功

    查看 cat user_passwd 

    继续添加用户

     htpasswd user_passwd user2

    或者  htpasswd -b user_passwd user3 123456

    删除一个用户
    [root@centos1 conf]# htpasswd -D user_passwd admin

    nginx里配置
    location /admin{
                auth_basic "auth: ";
                auth_basic_user_file /usr/local/nginx/conf/user_passwd;
               }
    然后重启nginx
    打开后台网址后显示

    不然会出现

    401 Authorization Required

  • 相关阅读:
    H5分栏(第一章)
    数据库操作集合
    sql 存储过程
    数据库事务
    Sql 分页三种方式
    GridView 后台分页
    GridView 分页 上一页 下一页 跳转 前端分页
    GridView 分页
    web前端开发分享-css,js入门篇(转)
    Intellij IDEA,WebStorm-keymap(转)
  • 原文地址:https://www.cnblogs.com/prettrywork/p/9431650.html
Copyright © 2011-2022 走看看