nginx-http-sysguard模块
一、作用
防止因nginx并发访问量过高或者遭受攻击造成服务器宕机,可根据负载设置界面跳转。
二、安装配置
1.下载模块软件包
wget https://github.com/alibaba/nginx-http-sysguard/archive/master.zip
unzip /opt/master.zip
2.给nginx打nginx_sysguard补丁
cd /nginx源文件目录
patch -p1 < nginx-http-sysguard-master/nginx_sysguard_1.3.9.patch
3.编译nginx添加模块
nginx -V查看nginx编译选项
[root@myhost nginx-1.14.0]# nginx -V
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_sub_module --with-stream --with-stream_ssl_module --with-openssl=/opt/hdlnmp/src/openssl-1.0.2o
重新编译,增加模块
./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可执行程序
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值根据实际需求自行调节。
sysguard on;sysguard_load load=0.01 action=/loadlimit;sysguard_mem swapratio=20% action=/swaplimit;location = /loadlimit {return 503;}location /swaplimit {return 503;}
可修改配置页面跳转
sysguard on;sysguard_load load=0.01 action=/crowded.html;#sysguard_load load=0.01 action=/error_page/index.html;
5.重启nginx
service nginx restart
crowded.html(放到项目根目录)
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>国家海洋博物馆</title><style type="text/css">.box {position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);-ms-transform: translate(-50%, -50%);/* IE 9 */-webkit-transform: translate(-50%, -50%);/* Safari and Chrome */-o-transform: translate(-50%, -50%);/* Opera */-moz-transform: translate(-50%, -50%);/* Firefox */}.box img {display: block;width: 3.85rem;}.box p {font-size: 0.28rem;color: #000;text-align: center;line-height: 1.5rem;}</style></head><body><div class="box"><img src="https://img-blog.csdnimg.cn/2022010617585034894.jpeg" /><p>太热情了,请稍后再来吧</p></div><script type="text/javascript">(function(doc, win) {var docEl = doc.documentElement,resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',recalc = function() {var clientWidth = docEl.clientWidth;if(!clientWidth) return;if(clientWidth >= 750) {docEl.style.fontSize = '100px';} else {docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';}};if(!doc.addEventListener) return;win.addEventListener(resizeEvt, recalc, false);doc.addEventListener('DOMContentLoaded', recalc, false);})(document, window)</script></body></html>
nginx-http-sysguard模块相关推荐
- 1. nginx扩展——ngx_lua 模块简介、安装
1. 简介 lua-nginx-module(ngx_lua module)把 Lua5.1 的解释器 或 LuaJIT 2.0/2.1 的解释器嵌入到 nginx 中,将强大的 Lua 线程(L ...
- Nginx源码研究之nginx限流模块详解
这篇文章主要介绍了Nginx源码研究之nginx限流模块详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧 高并发系统有三把利器:缓存.降级和限流: 限流的目的是通过对并 ...
- Nginx安装echo模块
echo-nginx-module 模块可以在Nginx中用来输出一些信息,可以用来实现简单接口或者排错. 项目地址:https://github.com/openresty/echo-nginx-m ...
- 宝塔nginx文件服务器,宝塔面板nginx编译webdav模块 – 建立webdav服务器
要想Nginx支持WebDAV,需要手动添加http_dav_module和nginx-dav-ext-module模块.http_dav_module模块是nginx默认的模块,但是也需要手动编译. ...
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块(转)
1.Nginx的FastDFS模块什么作用? 我们在使用FastDFS部署一个分布式文件系统的时候,通过FastDFS的客户端API来进行文件的上传.下载.删除等操作.同时通过 FastDFS的HTT ...
- httpd开启status模块_Nginx高并发系列之二——Nginx开启ssl模块
在上一期中我们安装配置了nginx1.13.7版本并且成功启动,那么这一期就针对安装的Nginx支持ssl模块--即开启https功能.如果还有不知道如何安装与配置的请移至: 水番丘山:Nginx高并 ...
- Mac系统安装nginx+rtmp模块
1.安装命令 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install) ...
- linux第三方模块参数,nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下)...
nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下),安装Nginx和HttpAccessKeyModule模块(参考LNMP环境 ...
- Nginx学习之七-模块ngx_epoll_module详解(epoll机制在nginx中的实现)
本文结合实际代码介绍事件驱动模块接口与epoll用法是如何结合起来发挥作用的.Nginx中ngx_epoll_module模块基于epoll实现了Nginx的事件驱动. 模块定义(src/event/ ...
- Nginx Image缩略图模块加强网站运行速度
Nginx Image缩略图模块加强网站运行速度 在大型网站实际开发当中,大家都会遇到关于图片压缩的处理,传统的方法是自己开发一套图片处理的服务,根据需求生成不同图片.这样是可以解决问题.但是个人感觉 ...
最新文章
- 人均 11878 元,2020 年研发岗年终奖最高!技术、产品岗均榜上有名
- 用户操作计算机系统的基本工具是什么,在Windows支持下,用户操作计算机系统的基本工具是______。...
- Table of Contents - Tomcat
- 计算机中用户权利和用户权限,揭秘:Win7系统用户和组权限说明
- springboot+maven实现模块化编程
- 侣信即时通讯系统的技术解析
- 程序员修仙之路--设计一个实用的线程池
- matlab平滑曲线_梯度下降法实现路径平滑
- 前后端分离项目部署_不用Docker前后端分离项目如何快速部署
- ftp服务器设置上文件大小,ftp服务器文件上传大小设置
- C# 名称空间的别名
- python变成exe1023无标题_GitHub - Qing1023/Python-100-Days: Python - 100天从新手到大师
- 当前数据中心运维管理工作中存在的问题
- 关于String字符串的比较
- Vue组件里初始化组件,一对多
- python第二周基本图形绘制
- 【Axure视频教程】第20章 全局变量
- 简单对比4G的两种模式
- 基于javaweb+jsp的设备维修管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap)
- 对于有抱负的软件开发人员:采访是一条两条路