nginx-http-sysguard模块

一、作用防止因nginx并发访问量过高或者遭受攻击造成服务器宕机,可根据负载设置界面跳转。 二、安装配置1.下载模块软件包

<pre class="brush:bash;gutter:true;">wget https://github.com/alibaba/nginx-http-sysguard/archive/master.zip
unzip /opt/master.zip

2.给nginx打nginx\_sysguard补丁

<pre class="brush:bash;gutter:true;">cd /nginx源文件目录
patch -p1 < nginx-http-sysguard-master/nginx_sysguard_1.3.9.patch 

3.编译nginx添加模块 nginx -V查看nginx编译选项


<pre class="brush:bash;gutter:true;">nginx version: nginx/1.14.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.0.2o  27 Mar 2018
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http

重新编译,增加模块

<pre class="brush:bash;gutter:true;">./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl=/opt/hdlnmp/src/openssl-1.0.2o --add-module=nginx-http-sysguard-master
make

替换nginx可执行程序

<pre class="brush:bash;gutter:true;">cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
cp ./objs/nginx /usr/local/nginx/sbin/

4.配置nginx文件 添加如下内容,可在http、server、location段配置,load值根据实际需求自行调节。

<pre class="brush:bash;gutter:true;">        sysguard on;
        sysguard_load load=0.01 action=/loadlimit;
        sysguard_mem swapratio=20% action=/swaplimit;
        location = /loadlimit {
            return 503;
        }
        location /swaplimit {
            return 503;
        }    

可修改配置页面跳转

<pre class="brush:bash;gutter:true;">        sysguard on;
        sysguard_load load=0.01 action=/error_page/index.html;   

5.重启nginx

<pre class="brush:bash;gutter:true;">service nginx restart

标签: nginx, 服务器, http, 负载, module, load, sysguard

相关文章推荐

添加新评论,含*的栏目为必填