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;
}
}
 

nginx配置用户认证的更多相关文章

  1. nginx 配置用户认证

    nginx 配置用户认证有两种方式: 1.auth_basic 本机认证,由ngx_http_auth_basic_module模块实现.配置段: http, server, location, li ...

  2. LNMP配置——Nginx配置 —— 用户认证

    一.配置 再来创建一个新的虚拟主机 #cd /usr/local/nginx/conf/vhost #vi test.com.conf 写入: server { listen 80; server_n ...

  3. nginx 添加用户认证

    nginx 添加用户认证  nginx 配置文件添加: 配置代理添加用户认证:server {   listen       ;   server_name localhost;   location ...

  4. Nginx网站用户认证

    一.Nginx网站用户认证 用户认证:用户访问网页时需要输入一个用户名和密码才能打开网页. nginx的默认网页时安装目录下的html/index.html,配置文件在安装目录下的conf目录中的ng ...

  5. nginx访问控制用户认证两种方式

    一.用户认证1.首先需要用http来生成密码文件即安装apache :yum install -y httpd 生成密码文件:htpasswd -c /usr/local/nginx/conf/htp ...

  6. 三、Nginx设置用户认证

    要求:通过nginx服务端配置实现以下目标 访问web页面需要进行用户认证. 用户名为:tom,密码:123456 操作步骤, 更改配置文件 [root@client ~]# vim /usr/loc ...

  7. Nginx 配置 Basic 认证

    /* * 环境:LNMP(CentOS 6.6 + Nginx 1.8.0) */ 在 Nginx 下配置 Basic 认证需要依靠 Nginx 的 http_auth_basic_module 模块 ...

  8. Apache配置--用户认证(针对目录访问)-update2015-05-02

    通过Apache配置可以限制用户对目录的访问,会弹出像phpadmin一样的登陆框. ========================================================= ...

  9. redis配置用户认证密码

    1,下载安装 Download, extract and compile Redis with: $ wget http://download.redis.io/releases/redis-3.2. ...

随机推荐

  1. Educational Codeforces Round 10 A. Gabriel and Caterpillar 模拟

    A. Gabriel and Caterpillar 题目连接: http://www.codeforces.com/contest/652/problem/A Description The 9-t ...

  2. 解决Could not open input file: think问题

    前几天做项目的时候,突然想用命令行创建TP5的控制器以及模型等 输入命令: >php think make:controller admin/Abc 报错如下: Could not open i ...

  3. SEPIC 单端初级电感转换器 稳压器 -- Zeta 转换器

    single ended primary inductor converter 单端初级电感转换器 SEPIC(single ended primary inductor converter) 是一种 ...

  4. directio mysql 编绎选项

    http://www.myexception.cn/linux-unix/495407.html http://www.iyunv.com/thread-25950-1-1.html

  5. hdu 2176 取石子游戏

    http://acm.hdu.edu.cn/showproblem.php?pid=2176 提示:尼姆博弈,异或 #include <iostream> #include <cst ...

  6. Setup SS5 Socks Proxy

    Install and configure ss5 socks proxy with simple authentication SS5 is a high performance socks pro ...

  7. 2014 百度之星 题解 1004 Labyrinth

    Problem Description 度度熊是一仅仅喜欢探险的熊,一次偶然落进了一个m*n矩阵的迷宫,该迷宫仅仅能从矩阵左上角第一个方格開始走,仅仅有走到右上角的第一个格子才算走出迷宫,每一次仅仅能 ...

  8. 一个 forceLayout() 和 requestLayout() 的测试

    两个view: 一个是系统默认的FrameLayout,  A 一个是自己自定义的MyView extends View,重载了onMeasure函数(): B @Override protected ...

  9. C++内存管理学习堆和栈

    来源:http://c.chinaitlab.com/basic/936306_2.html 一 C++内存管理 1.内存分配方式 在讲解内存分配之前,首先,要了解程序在内存中都有什么区域,然后再详细 ...

  10. Tomcat与Servlet工作流程

    什么是Tomcat? Tomcatserver是一个免费的开放源码的Web 应用server,属于轻量级应用server. 什么是Servlet? Servlet是在server上执行的小程序.,说白 ...