zoukankan      html  css  js  c++  java
  • nginx--模块2--基于用户

    基于用户_明文传输http

    工具安装,yum install -y httpd-tools 

    设置用户名和密码htpasswd -b -c /etc/nginx/.auth.conf testnginx 123456

    /etc/nginx/conf.d/default.conf中在监控部分添加

    location /status {
    stub_status;
    access_log off;
    deny 10.0.0.1;
    allow all;
    auth_basic 'test';    //个别浏览器提示引号内容,如火狐
    auth_basic_user_file /etc/nginx/.auth.conf; //认证文件
    }

    访问控制

    #limit_conn_zone $binary_remote_addr zone=conn_zone:10M;               //公共部分基于tcp连接,接收10M大的ip地址,其中红色字体可以变
    limit_req_zone $binary_remote_addr zone=req_test:10m rate=1r/s;    //公共部分基于请求连接,接收10M地址和容许每个地址中每秒1个请求,其中红色字体可以变
    server {
    listen 80;
    server_name localhost;
    location / {
    root /usr/share/nginx/html;
    index index.html index.htm;
    #limit_conn zone=conn_zone1;
    limit_req zone=req_test;

    }

    .....

    }

    压测ab -n 50 -c 20 http://192.168.3.222/index.html   //20个主机同时发送50个请求

    因每秒接收1个请求,剩下延时处理,主机处理请求1个,所以只有1个成功49个失败

    改每秒10个

     

    依然失败49个

     

    每秒处理1个请求burst定义请求数量,超出部分返回503

     

    10请求,3并发,错误4个

  • 相关阅读:
    黄金连分数
    第39级台阶
    四、绘图可视化之Seaborn
    三、绘图和可视化之matplotlib
    二、pandas入门
    python_111_动态导入模块
    爬虫_python3_抓取猫眼电影top100
    爬虫_python3_urllib
    python_112_网络编程 Socket编程
    python_111_异常处理
  • 原文地址:https://www.cnblogs.com/Leaders543/p/12491462.html
Copyright © 2011-2022 走看看