是否可以将NON-http连接请求转发到nginx中的其他端口? [英] Is it possible to forward NON-http connecting request to some other port in nginx?
问题描述
我在我的服务器上运行nginx,监听端口80和433.我知道nginx有多种端口转发方式,允许我转发请求,如: http:// myserver:80 / subdir1 到某个地址,如: http:// myserver:8888 。
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/subdir1 to some address like: http://myserver:8888.
我的问题是可以配置nginx以便我可以转发 NON -http请求(只有那些普通TCP连接)到其他一些端口?测试它是否是一个http请求非常容易,因为第一个字节将是GET或POST。这是示例。
My question is it possible to configure nginx so that i can forward NON-http request (just those plain TCP connection) to some other port? It's very easy to test if it's a http request because the first bytes will be either "GET" or "POST". Here's the example.
连接到nginx的客户端。
客户发送:
The client connected to nginx . The client send:
a。 HTTP get请求:GET / HTTP 1.1:HTTP的一些规则
a. HTTP get request: "GET / HTTP 1.1": some rule for HTTP
b。任何无法识别为HTTP标头的字节:将其转发到其他端口,例如,888,999等。
b. Any bytes that can't be recognized as HTTP header: forward it to some other port, say, 888, 999, etc.
技术上可行吗?或者你会建议一种方法吗?
Is it technically possible? Or would you suggest a way to do this?
推荐答案
这在技术上是可行的。
您可以修改名为 nginx_tcp_proxy_module 或 HAproxy 。
或者你可以写一个与上面类似的nginx模块为你做这个。
Or you can write a nginx module similar to above one to do this for you.
这篇关于是否可以将NON-http连接请求转发到nginx中的其他端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!