微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

nginx中的大量端口转发

我正在尝试在Nginx配置中添加20K端口(范围[40k-60k])的映射.
此配置已添加Nginx.conf中

stream{
    server {
        listen 40000;
        listen 40001;
        .
        .
        .
        listen 60000;
        proxy_pass <backend-url>:$server_port;
     }
}

当映射数量<1时,一切都很好用. 500.但是当它增加到20K映射时,响应的延迟是巨大的.添加端口转发的任何解决方法或任何其他方法

解决方法:

我试图通过iptables而不是Nginx来完成它

https://www.cyberciti.biz/faq/linux-port-redirection-with-iptables/

You can easily redirect incoming traffic by inserting rules into
PREROUTING chain of the nat table. You can set destination port using
the REDIRECT target

iptables -t nat -A PREROUTING -p tcp --dport 1:65535 -j REDIRECT --to-ports 10000

并在Nginx中监听端口10000

相关讨论:https://superuser.com/questions/440324/iptables-how-to-forward-all-external-ports-to-one-local-port

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐