• 记录Nginx模块开发


    • --with-http_stub_status_module模块:Nginx的客户端状态

                Syntax:stub_status

                Default:--

                Content:server,location

    location /mystatus{

       stub_status;

    }

    >>效果图

    • --with-http_random_index_module模块:目录中选择一个随机主页

                Syntax:random_index on|off

                Default:random_index off;

                Content:location

    location /{

       root  随机文件的文件夹;

       random_index on;

    }

    • --with-http_sub_module模块:http内容替换

                Syntax:sub_filter string replacement

                Default:--

                Content:http,server,location

    location /{

      sub_filter '被替换值' '替换值';

    }

    • --with-http_limit_conn_module模块:连接限制

                Syntax:limit_conn_zone key zone=name:size;

                Default:--

                Content:http

                Syntax:limit_conn [zone] number;

                Default:--

                Content:http,server,location

    limit_conn_zone $binary_remote_addr zone=conn_zone:1m;

    server{  

      location / {

               limit_conn conn_zone 1;

      }

    }

    • --with-http_limit_req_module模块:请求限制

                Syntax:limit_req_zone key zone=name:size rate=size;

                Default:--

                Content:http

                Syntax:limit_req zone=name [burst=number][nodelay];

                Default:--

                Content:http

    limit_req_zone $binary_remote_addr zone=req_zone:1m rate=1r/s;

    server{  

      location / {

               #limit_req zone=req_zone;

               #limit_req zone=req_zone burst=3;

               #limit_req zone=req_zone burst=3 nodelay;
    }
    • --with-http_access_module模块:访问控制-基于IP的访问控制

                Syntax:allow address | CIDR | unix: |all;

                Default:--

                Content:http,server,location,limit_except;

                Syntax:deny address | CIDR | unix: |all;

                Default:--

                Content:http,server,location,limit_except;

    server{  

      location / {

               root   /usr/share/nginx/html;

               index  index.html index.htm;

           }

           location ~^ / 50x.html {

               root   /usr/share/nginx/html;

               #allow 117.30.57.5;

               #allow 117.30.57.5/40;#允许5-40IP地址段访问

               deny all;

           }

    }
    • --with-http_auth_basic_module模块:访问控制-基于用户的信任登陆

                Syntax:auth_basic string|off;

                Default:auth_basic off;

                Content:http,server,location,limit_except

                Syntax:auth_basic_user_file file;

                Default:--

                Content:http,server,location,limit_except


  • 相关阅读:
    C++静态库与动态库(转)
    Tornado异步
    Yacc与Lex
    云数据库
    linux如何查看端口被谁占用
    Innodb Double Write
    MySQL GTIDs(global transaction identifiers)
    Java并发编程:线程池的使用
    Oracle 建立索引及SQL优化
    解决redhat linux下IP地址可以ping通,域名无法ping通问题
  • 原文地址:https://www.cnblogs.com/chenbingquan/p/10711466.html
Copyright © 2020-2023  润新知