Configuring a TCP proxy with Nginx on Ubuntu 24.04

Install Nginx with stream module:

sudo apt install nginx-full

The output of the command

nginx -V

should contain with-stream=dynamic.

And add the following to /etc/nginx/nginx.conf:

stream {
    server {
        listen 12345;                    # The port that Nginx listens to
        proxy_pass 192.168.0.121:389;    # Where to forward connections
    }
}

Reload Nginx configuration:

sudo nginx -t
sudo service nginx reload

Ensure the port is open:

telnet localhost 12345

Leave a Reply

Your email address will not be published. Required fields are marked *