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. hust 1385 islands 并查集+搜索

    islands Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/problem/show/1385 Descri ...

  2. mySql---logback日志写入数据库(mysql)配置

    如题  建议将日志级别设置为ERROR.这样可以避免存储过多的数据到数据中. 1  logback 配置文件(如下) <?xml version="1.0" encoding ...

  3. TPS61175/TPS55340 3A/5A、40V 电流模式集成 FET 升压 DC/DC 转换器

    集成型5A 40V 宽输入范围升压/单端初级电感转换器(SEPIC) / 反激式(Flyback) 直流到直流稳压器 (Rev. B) 描述 TPS55340 是一款单片非同步开关稳压器,此稳压器带有 ...

  4. Unused port adds a PWM/analog channel to a microcontroller

    Low-cost, 8-bit, single-chip microcontrollers are stingy when it comes to on-chip PWM (pulse-width-m ...

  5. MYSQL Out of resources when opening file './xxx.MYD' (Errcode: 24)

    出现Out of resources when opening file './xxx.MYD' (Errcode: 24)错误是因为打开的文件数超过了my.cnf的--open-files-limi ...

  6. 【实体 报错 】No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer

    HTTP Status 500 - Could not write content: No serializer found for class org.hibernate.proxy.pojo.ja ...

  7. C++入门级 一

    如果您想学习电脑编程,却又不知从何入手,那么您不妨看看下面的几种学习方案,可能会给您一些启示吧! 方案一 Basic语言 & Visual Basic 优点 (1)Basic 简单易学,很容易 ...

  8. .NET:CLR via C# The CLR’s Execution Model

    The CLR’s Execution Model The core features of the CLR memory management. assembly loading. security ...

  9. HTML+CSS网站开发兵书

    <HTML+CSS网站开发兵书> 基本信息 作者: 高洪涛 丛书名: 程序员藏经阁 出版社:电子工业出版社 ISBN:9787121212369 上架时间:2013-8-26 出版日期:2 ...

  10. haitaolab.com 我的新网站,欢迎访问

    从博客园到csdn,再到新浪云博客,最近终于下决心购买空间和域名建立自己的独立网站! 在这里也建议希望建立自己独立博客的朋友尽快行动吧! 我的新的网站“海淘实验室”专注于介绍和分享海淘资讯,欢迎大家访 ...