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

Nginx 的 stream 和 http 可以配置为同一端口吗

  •  
  •   Techxiu · Apr 16, 2020 · 5346 views
    This topic created in 2241 days ago, the information mentioned may be changed or developed.

    例如下面这样

    http {
         server {
             listen 443 ssl;
             server_name www.example.com;
         }
     }
    
    stream {
        server {
            listen 443;
            ssl_preread on;
            proxy_pass $name;
        }
    }
    

    试了好像不行,会提示

    nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)

    3 replies    2020-04-17 14:30:38 +08:00
    lance86
        1
    lance86  
       Apr 16, 2020
    http 是基于 tcp 的,stream 默认也是监听 tcp 协议的( stream 可以指定为监听 udp,这时应该就可以配置为同一个端口了),两者就不能监听同一个端口了。
    核心就是端口是传输层协议在用的,tcp 、udp 这些的。
    zhuisui
        2
    zhuisui  
       Apr 16, 2020
    traefik 是可以的
    julyclyde
        3
    julyclyde  
       Apr 17, 2020
    你既然都试了不能,为什么还要问能不能呢
    至少问个为什么啊?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3019 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 09:04 · PVG 17:04 · LAX 02:04 · JFK 05:04
    ♥ Do have faith in what you're doing.