› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
wslsq
V2EX  ›  NGINX

[不懂就问]请问 nginx 如何多 ip 监听多端口?谢谢

  •  
  •   wslsq · Jul 18, 2019 · 4093 views
    This topic created in 2668 days ago, the information mentioned may be changed or developed.

    在网上查了一下资料,nginx 监听端口只能一行一行写,比如

    listen 80;

    listen 8888;

    =====那么问题来了=====

    假设有 ip 1.1.1.1-1.1.1.200

    每个 ip 监听 1000 个端口,8000-9000 端口

    那我是不是该写 200*1000 个 listen 吗.

    这样岂不是会卡炸,也不方便后续维护,请问一下各位大佬有什么好方法吗?谢谢

    zzen
    zzen
    Jul 18, 2019
    1
    关键是为啥要监听那么多的 IP 和端口,
    ChoateYao
    ChoateYao
    Jul 18, 2019❤️1
    2
    用防火墙转发就能解决你的问题了,这个不是 Nginx 做的事情。
    janxin
    janxin
    Jul 18, 2019❤️1
    3
    这边不建议您用 nginx 做呢,要么 iptables 做一下?

    虽然你这个需求理论上出现可能性极低
    wslsq
    wslsq
    OP
    Jul 18, 2019
    4
    @janxin 哈哈我倒是真的要用上了,谢谢建议我去看看 iptables
    wslsq
    wslsq
    OP
    Jul 18, 2019
    5
    @ChoateYao 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2124 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 02:50 · PVG 10:50 · LAX 18:50 · JFK 21:50
    ♥ Do have faith in what you're doing.