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

NGINX UDP 透明代理问题

  •  
  •   2ME · 2021-07-02 12:19:35 +08:00 · 3025 次点击
    这是一个创建于 1021 天前的主题,其中的信息可能已经有所发展或是发生改变。

    gateway 172.0.0.1 NGINX(Kong) UDP 监听 53 端口
    udp-server 172.0.0.2 监听 30053 端口
    nginx 配置了透明代理proxy_bind $remote_addr transparent;
    配置后 udp-server 可以正常获取到客户端 ip 但是无法返回结果给客户端
    想问一下 iptable 怎么配置才能正常返回 网关和服务都是跑在 docker 里的
    这篇博客的 tc 命令返回值都是 Illegal "match"
    相关问题 https://forum.nginx.org/read.php?11,268467

    9 条回复    2021-07-15 15:11:32 +08:00
    2ME
        1
    2ME  
    OP
       2021-07-02 15:23:30 +08:00
    在 output 链配置了 DNAT 不生效 Reply from unexpected source: gateway#53, expected udp-server#300553
    2ME
        2
    2ME  
    OP
       2021-07-02 15:25:43 +08:00
    #1 Reply from unexpected source: udp-server#30053, expected gateway#53
    guo4224
        3
    guo4224  
       2021-07-06 12:09:15 +08:00
    策略路由,或者直接把默认路由设置成你的 nginx 机器。其他的 haproxy 也是一样
    2ME
        4
    2ME  
    OP
       2021-07-06 12:14:15 +08:00 via iPhone
    @guo4224 这个好像不解决端口不匹配的问题
    learningman
        5
    learningman  
       2021-07-06 13:55:55 +08:00
    iptables MASQUERADE
    2ME
        6
    2ME  
    OP
       2021-07-06 14:15:04 +08:00
    @learningman MASQUERADE 只是 ip 伪装 不解决 port 不一致的问题
    guo4224
        7
    guo4224  
       2021-07-09 13:39:28 +08:00
    @2ME 端口不匹配是什么鬼?
    2ME
        8
    2ME  
    OP
       2021-07-09 15:38:23 +08:00
    @guo4224 入口是 nginx 监听的 53 端口 server 发起回复是 30053 端口 客户端发现回复的端口和发起请求的端口不一致会拒绝的 参考 2 楼的报错信息
    2ME
        9
    2ME  
    OP
       2021-07-15 15:11:32 +08:00
    http://disq.us/p/292lyfk 不知道 tc pedit 能不能解决这个问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3359 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 11:34 · PVG 19:34 · LAX 04:34 · JFK 07:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.