nginx+lua实现灰度发布/waf防火墙
阅读原文时间:2023年07月08日阅读:3

nginx+lua 实现灰度发布 waf防火墙

课程链接:【课程】Nginx 与 Lua 实现灰度发布与 WAF 防火墙(完)_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili

Nginx基础 - Nginx+Lua实现灰度发布与WAF - 暗香流行风缥缈 - 博客园

Nginx+Lua实现WAF引用防火墙_李在奋斗的博客-CSDN博客

安装luajit解释器

重新编译nginx #或者选择openrestry

luajit 环境

模块:ngx_devel_kit 和lua-nginx-module

#安装lua
yum install lua

#下载最新luajit和编译安装nginx模块ngx_devel_kit 和lua-nginx-module
#给luajit库加上软连接

#加载lua的lib库到/etc/ld.so.conf

#$?判断编译安装是否成功

注意location里写的

default_type text/html;

content_by_lua_block{

}

简单

3台服务器

①nginx+lua+memcache

②java-生产

③java-测试

数字0和空字符串 = true
布尔类型只有nil和false

脚本以.lua结尾

~=是不对等于
字符串拼接  .. 为+
io对象可以根据用户输入读取,输入,类似read

创建jsp文件,当访问tomcat时返回html页面。

(11 封私信 / 67 条消息) 什么是JSP技术? - 知乎

除了安装memcache,还需要配置memcached支持lua

nginx配置include conf.d/*.conf;

配置在nginx/conf.d/lua.conf中

#必须在http层
lua_package_path "/etc/nginx/lua/memcached.lua";
upstream java_prod {
server 192.168.56.12:8080;
}
upstream java_test {
server 192.168.56.13:9090;
}
server {
listen 80;
server_name 47.104.250.169;
location /hello {
default_type 'text/plain';
content_by_lua 'ngx.say("hello ,lua scripts")';
}
location /myip {
default_type 'text/plain';
content_by_lua '
clientIP = ngx.req.get_headers()["x_forwarded_for"]
ngx.say("Forwarded_IP:",clientIP)
if clientIP == nli then
clientIP = ngx.var.remote_addr
ngx.say("Remote_IP:",clientIP)
end
';
}
location / {
default_type 'text/plain';
content_by_lua_file /etc/nginx/lua/dep.lua;
}
location @java_prod {
proxy_pass http://java_prod;
include proxy_params;
}
location @java_test {
 proxy_pass http://java_test;
include proxy_params;
}
}

#这是在/etc/nginx/目录下
//nginx反向代理理tomcat,必须配置头部信息否则返回400错误
[root@nginx-lua conf.d]# cat ../proxy_params
proxy_redirect default;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 32k;
proxy_buffering on;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_max_temp_file_size 256k;

攻击手段

在这里插入图片描述

解决办法

安装lnmp

创建一张info表写入账户密码信息,测试

网站登陆页面

提交表单时,php连接数据库

sql登陆注入

” 空格 or 1=1 #

号把后面注释掉,1=1为true,or条件判断为真

如果服务器没有git命令,使用yum安装

git clone==下载代码

修改规则目录下post文件

html=就是阻止访问后的访问页面

cc貌似是针对域名,ddos是针对ip

ccrate=100/60 #一个域名,60秒最多访问100次,超过将封掉

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章