Welcome! Log In Create A New Profile

Advanced

Offload TCP traffic to another process

November 28, 2019 03:33PM
Dear experts,

We are evaluating nginx as a platform for the product of our new startup company.

Our use-case requires a TCP proxy that will terminate TLS, which nginx handles very well. However, we need to be able to send all TCP traffic to another process for offline processing.

Initially we thought we could write a NGX_STREAM_MODULE (call it tcp_mirror) that will be able to read both the downstream bytes (client <--> nginx) and upstream bytes (proxy <--> server) and send them to another process, but after looking at a few module examples and trying out a few things we understood that we can only use a single content handler for each stream configuration.

For example, we were hoping the following mock configuration would work for us, but realized we can't have both proxy_pass and tcp_mirror under server because there can be only one content handler:
stream {
server {
listen 12346;
proxy_pass backend.example.com:12346;
tcp_mirror processor.acme.com:6666;
}
}

The above led us to the conclusion that in order to implement our use-case we would have to write a new proxy_pass module, more specifically we would have to re-write ngx_stream_proxy_module.c. The idea is that we would manage two upstreams, the server and the processor. The configuration would look something like this:
stream {
server {
listen 12346;
proxy_pass_mirror backend.example.com:12346 processor.acme.com:6666;
}
}

Before we begin implementation of this design, we wanted to consult with the experts here and understand whether anyone has a better idea on how to implement our use-case on top of nginx.

Thanks in advance,
Yoav Cohen.
Subject Author Posted

Offload TCP traffic to another process

yoav.cohen November 28, 2019 03:33PM

Re: Offload TCP traffic to another process

Marcin Wanat November 28, 2019 05:40PM

Re: Offload TCP traffic to another process

alon.ludmer November 29, 2019 02:26AM

Re: Offload TCP traffic to another process

Patrick November 28, 2019 07:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 175
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready