Openresty/Lua返回默认错误页面而不是自定义
2020-7-27 9:38:9
收藏:0
阅读:259
评论:1
我目前正在尝试使用此脚本设置WAF / DDOS保护: https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/blob/master/lua/anti_ddos_challenge.lua
除了Openresty / nginx返回默认的500错误页面而不是下面显示的自定义error_page之外,一切都运作良好,如果其中一个WAF规则被命中。请参见上面的脚本中的“WAF_URI_Request_table”。
每次请求被这些WAF规则阻止时,我还会在日志中获得以下条目:
2020/07/27 09:20:29 [error] 150#150: * 16在内部重定向到“/ 403.html”时重写或内部重定向周期,客户端:172.21.0.5,服务器:localhost,请求:“GET /test.php HTTP /1.1”,主机:“localhost”
我的nginx配置如下(缩短):
...
http {
upstream backend {
server 127.0.0.1:8000 max_fails = 3 fail_timeout = 60s;
}
...
server {
listen 80;
access_by_lua_file ddos_challenge.lua;
aio threads = default;
...
location @ proxy_to_app {
proxy_pass http://backend;
aio threads;
proxy_read_timeout 100s;
proxy_connect_timeout 100s;
proxy_http_version 1.1;
proxy_redirect off;
proxy_buffers 16 4k;
proxy_buffer_size 2k;
proxy_intercept_errors on;
proxy_set_header Host $host;
uwsgi_intercept_errors on;
gzip on;
gzip_min_length 1024;
gzip_comp_level 3;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
}
location / {
try_files $uri @ proxy_to_app;
}
...
error_page 412 414 416 444 495 496 497 500 501 502 504 507 /custom_error.html;
location = /custom_error.html {
root /app/templates/;
internal;
}
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

发现了错误,参见:
https://groups.google.com/g/openresty-en/c/1XASYFeP61o?pli=1
我将 access_by_lua 行移动到了 / 位置块中,就是这样。