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

nginx 的 lua 模块 怎样实现 tcp 代理验证?

  •  
  •   fingerstyle · 2017-03-31 16:41:52 +08:00 · 4261 次点击
    这是一个创建于 2575 天前的主题,其中的信息可能已经有所发展或是发生改变。
    nginx 只用到 tcp 模块做 4 层的代理,作为 http 代理服务器,模块取自 https://github.com/yaoweibin/nginx_tcp_proxy_module

    现在想对代理做验证,只允许经过验证的用户使用nginx代理。可以是 ip 认证,但最好是帐号密码认证。帐号密码验证不要像 HTTP Auth Basic 那样关了浏览器就还要重新输入,最好能在一段时间内持续保持登录状态。

    想知道这样的需求该怎么写 lua 脚本。。。对openresty社区了解的不多。。求助各位 不知道有没有现成的

    网上找到的参考资料:
    http://www.oschina.net/translate/writing-an-nginx-authentication-module-in-lua?cmp


    另外还想过一个办法,写一个web页面让用户登录,过程中将用户的ip加入到白名单。已经有人试过这种方法,但用的是squid,个人觉得不如nginx_lua好用
    http://www.cnblogs.com/hahp/p/4224560.html
    6 条回复    2017-04-01 06:56:37 +08:00
    knightdf
        1
    knightdf  
       2017-03-31 17:02:21 +08:00
    cookie?
    fingerstyle
        2
    fingerstyle  
    OP
       2017-03-31 19:13:55 +08:00
    lua 可以实现吗
    Phant0m
        3
    Phant0m  
       2017-03-31 19:18:46 +08:00
    验证通过的用户注入 cookies ,设置 cookies 过期时间 就可以
    fingerstyle
        4
    fingerstyle  
    OP
       2017-03-31 19:26:31 +08:00
    有现成的轮子吗。。
    zingl
        5
    zingl  
       2017-03-31 20:36:30 +08:00
    > 不要像 HTTP Auth Basic 那样关了浏览器就还要重新输入

    该换浏览器了
    ericFork
        6
    ericFork  
       2017-04-01 06:56:37 +08:00
    https://www.v2ex.com/t/344704

    没有,也不可能简单地实现你的需求。要么自己去研究造轮子,要么就多读书吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   954 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:17 · PVG 05:17 · LAX 14:17 · JFK 17:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.