S
S
sound2014-01-23 13:33:50
Nginx
sound, 2014-01-23 13:33:50

How to process each TCP packet in nginx?

The protocol is not HTTP.
A slightly modified port forwarding is needed.
You need to learn how to redirect incoming TCP traffic to a dynamically changing server:port. In this case, it is necessary that with each arrival of a TCP packet (from both sides), a callback is called, where it would be possible to read and change the contents of the data field.
Actually questions:
- how can tcp traffic be redirected to an arbitrary one without breaking the incoming socket?
- which nginx module or function is responsible for processing each packet, and whether the described callback can be hung.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
Fedor Indutny, 2014-01-23
@donnerjack13589

Maybe it makes sense to use HAProxy instead of nginx? As far as I understand, it is more suitable for these purposes.

S
Sergey, 2014-01-23
@bondbig

nginx will not be able to work with non -HTTP protocol. You need to use either firewall tools (iptables / netfilter on linux), or, if balancing is needed, then other solutions, such as IPVS or HA-proxy.

S
Sergei Borisov, 2014-01-24
@risik

There is such a module: https://github.com/yaoweibin/nginx_tcp_proxy_module
I have not tried it myself, I will not answer for the quality. As well as for the possibilities - whether it solves your problem. It is possible that in these sources you will find the answer to your questions.
But in fact, you or HAProxy (if for balancing) or make your own. Since the task is not quite standard.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question