zoukankan      html  css  js  c++  java
  • nginx 添加用户认证

    nginx 添加用户认证 

    nginx 配置文件添加;

    配置代理添加用户认证:
    server {   listen      
    80;   server_name localhost;   location / {      auth_basic "secret";      auth_basic_user_file /etc/nginx/conf.d/passwd.db;      proxy_pass http://localhost:2018;      proxy_set_header Host $host:2018;      proxy_set_header X-Real-IP $remote_addr;      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;      proxy_set_header Via "nginx";   } }

    安装 http 插件:

    yum install http -y

    添加账户密码:(账户密码文件会存在刚才配置的 /etc/nginx/conf.d/passwd.db 中)

    # htpasswd -b /etc/nginx/conf.d/passwd.db user1 passwd1
    # htpasswd -b /etc/nginx/conf.d/passwd.db user2 passwd2

    测试 http://ip/ 会有提示框 输入账户密码

  • 相关阅读:
    Swift 构造与析构
    Swift 协议
    Swift 扩展
    Swift 多态
    Swift 继承
    Swift 封装
    Swift 方法
    Swift 属性
    Swift 对象
    Swift 类
  • 原文地址:https://www.cnblogs.com/sharesdk/p/11384122.html
Copyright © 2011-2022 走看看