zoukankan      html  css  js  c++  java
  • 2019.9.23 ngin的访问控制 一共两种认证,第一种是基本认证,第二种是摘要认证

    1,基于用户的访问控制

    [root@localhost ~]# yum -y install httpd-tools.x86_64    //安装对应软件包

    [root@localhost ~]# htpasswd -c -d /usr/local/nginx/conf/xiong tom    //   -c是创建     创建目录xiong    创建用户tom        注意!注意!注意!:如果之前这个xiong的目录里面有用户,加-c的话会清空xiong里面的所有用户。

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

    [root@localhost ~]# chmod 400 /usr/local/nginx/conf/xiong      //给权限

    [root@localhost ~]# chown nginx:nginx /usr/local/nginx/conf/xiong       //修改属主 属组

    [root@localhost ~]# ll /usr/local/nginx/conf/xiong
    -r--------. 1 nginx nginx 18 9月 23 18:37 /usr/local/nginx/conf/xiong

    [root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf       //去主配置文件添加定义的访问控制

    server {
    listen 80;
    server_name www.crushlinux.com;

    charset utf-8;


    location / {
    root html/crushlinux;
    index index.html index.htm;
    auth_basic "secret"; 
    auth_basic_user_file /usr/local/nginx/conf/xiong;            //引用定义的访问控制
    }
    location /status {
    stub_status on;
    access_log off;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {

    测试访问控制,登入用户tom  密码是123456 

  • 相关阅读:
    Silverlight For WinEmbedded 的页面切换实现
    如何修改 MFC Dialog 窗体的类名???
    SWIFT 开发环境
    Windows 10 安装
    Microsoft Remote Tools
    WinCE 7.0 下如何获取全路径文件名的后缀?
    年终工作总结
    Win8.1 下安装 eVC++ 4.0
    何生成一个 WinCE 下文件全路径大于 MAX_PATH(260) 字节的文件路径?
    A+B Problem III
  • 原文地址:https://www.cnblogs.com/otherwise/p/11571182.html
Copyright © 2011-2022 走看看