V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
dzdh
V2EX  ›  NGINX

不借助 lua 的前提下怎么实现类似 cloudflare 的 5 秒盾

  •  
  •   dzdh · 112 天前 · 1590 次点击
    这是一个创建于 112 天前的主题,其中的信息可能已经有所发展或是发生改变。

    根据 cookie cookie 是个 sha1(random()) 没有 cookie ,set 一个,标记 visit=1 。

    每次访问 visit+1 ,visit 达到限流标准 就放静态页面提示等。

    不借助 lua 的前提下咋弄(主要不想用 openresty ,而 lua 支持最好的就是 openresty)

    11 条回复    2024-01-07 12:31:48 +08:00
    google2020
        1
    google2020  
       112 天前
    不想用 openresty ,你可以单独编译 ngx lua 模块。njs 也可以,你肯定要在 http server 部署代码,在后端写意义就不大了。
    Puteulanus
        2
    Puteulanus  
       112 天前
    之前有个 WAF 的贴 /t/950364
    guazao
        3
    guazao  
       112 天前
    c 模块不好写 说不定还有共享内存、异步通信
    还是老老实实用 openresty 吧
    adoal
        4
    adoal  
       112 天前   ❤️ 1
    如果用的是 deb 系发行版,可以安装 nginx-extras ,会带上 lua 模块。

    我也不喜欢装 openresty 打包的那个版本。主要是不喜欢打包的 rpm/deb 不符合 FHS ,用的是 everything-under-prefix 方式,程序/配置/数据/日志的目录在文件系统里还都是同样的 ownership……这样还打个屁的 rpm/deb 包。
    flyqie
        5
    flyqie  
       112 天前 via Android
    自己写个 nginx 模块实现?

    不用 lua 的话只能这样了。。
    rrfeng
        6
    rrfeng  
       112 天前 via Android
    ratelimit + errorpage
    lolizeppelin
        7
    lolizeppelin  
       112 天前
    @adoal
    可以自己做标准 rpm 打包,稍微改动下标准 nginx 打包文件就可以了
    %if %{with lua}
    %package mod-http-ndk
    Group: System Environment/Daemons
    Summary: Nginx HTTP ndk module
    Requires: nginx = %{epoch}:%{version}-%{release}

    %description mod-http-ndk
    %{summary}.

    %package mod-http-lua
    Group: System Environment/Daemons
    Summary: Nginx HTTP lua module
    Requires: nginx-mod-http-ndk = %{epoch}:%{version}-%{release}
    Requires: openresty-luajit = %{luajit_ver}
    Requires: openresty-core = %{core_ver}
    Provides: lua-nginx-module = %{lua_ver}

    %description mod-http-lua
    %{summary}.
    %endif

    ----
    %if %{with lua}
    --add-dynamic-module=./ngx_devel_kit-%{ndk_ver} \
    --add-dynamic-module=./lua-nginx-module-%{lua_ver} \
    %endif
    %if %{with luastream}
    --with-stream \
    --add-module=./stream-lua-nginx-module-%{lua_stream_ver} \
    %else
    --with-stream=dynamic \
    %endif
    adoal
        8
    adoal  
       112 天前
    @lolizeppelin 我知道可以自己打包……但我还是认为春哥这个偏执的操作开了个坏头,基于 OpenResty 的其它方案,比如 Kong 和 APISIX ,都无脑地沿用了 OpenResty 的约定
    lolizeppelin
        9
    lolizeppelin  
       112 天前
    @adoal
    把 Kong 和 APISIX 也打标准 rpm 包....
    fdghjk
        10
    fdghjk  
       112 天前
    为啥不想用 lua
    julyclyde
        11
    julyclyde  
       111 天前
    @adoal 哦原来 kong 和 apisix 也是 openresty 啊?

    openresty 作者确实比较恃才放旷
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2790 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 06:13 · PVG 14:13 · LAX 23:13 · JFK 02:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.