Is it possible to forward NON-http connecting request to some other port in nginx?

前端 未结 3 953
春和景丽
春和景丽 2020-12-23 12:17

I have nginx running on my server, listening port 80 and 433. I know nginx has a number ways of port forwarding that allows me to forward request like: http://myserver:80/su

相关标签:
3条回答
  • 2020-12-23 12:40

    It is possible since nginx 1.9.0:

    http://nginx.org/en/docs/stream/ngx_stream_core_module.html

    Something along these lines (this goes on top level of nginx.conf):

    stream {
        upstream backend {
            server backend1.example.com:12345;
        }
    
        server {
            listen 12345;
            proxy_pass backend;
        }
    }
    
    0 讨论(0)
  • 2020-12-23 12:46

    This is technically possible for sure.

    You can modify open source tcp proxies like nginx module called nginx_tcp_proxy_module or HAproxy.

    Or you can write a nginx module similar to above one to do this for you.

    0 讨论(0)
  • 2020-12-23 12:51

    if nginx remote proxying with HTTP, your client could use the HTTP CONNECT command, then it connects with the remote port and forwards all data as "raw" (or at least I think so).

    0 讨论(0)
提交回复
热议问题