zoukankan      html  css  js  c++  java
  • nginx配置用户认证

    location ~ .*admin.php$ {
                auth_basic "weifenglinux auth";
                auth_basic_user_file /usr/local/nginx/conf/.htpasswd;
                 include fastcgi_params;
            fastcgi_pass unix:/tmp/www.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
     
       }
    yum install -y httpd  (安装 htpasswd命令)
    类似apache创建密码文件
    htpasswd -c /usr/local/nginx/conf/.htpasswd weifeng
    New password:justdoit
    增加新用户
    htpasswd  /usr/local/nginx/conf/.htpasswd weifeng1
    New password:justdoit
     
     
    /usr/local/nginx/sbin/nginx -t
    /etc/init.d/nginx reload
     
    刷新页面需要用户认证
     
    实例配置:
     
    server {
         listen 80;
         server_name hk_grafana*******.cn;
         location / {
              auth_basic "grafana auth";
              auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
              proxy_pass http://172.********:32102/;
              proxy_redirect off;
              proxy_set_header Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             #client_max_body_size 100m;
                    }
          }
     
  • 相关阅读:
    checkListbox的单选
    IP地址控件CIPAddressCtrl类的使用
    C++ Socket编程步骤
    环形缓冲区
    隐式链接和显示链接的区别
    memset、memcpy的使用方法!
    cetlm下载地址
    安装 GCC
    centos 配置代理
    make软件包安装
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/9664095.html
Copyright © 2011-2022 走看看