Skip to main content

Nginx Reverse UDP & TCP Proxy

Reference:

Nginx Reverse Proxy:

Maybe you have Nginx as a front-end server on your cloud VPS, and you prefer to run back-end services on your own hardware, tunneled over a VPN.  The following can be added to the top-level nginx configuration (probably /etc/nginx/nginx.conf) to enable UDP and TCP reverse proxying to your back-end bootstrap node:

stream {

    server {
        listen     3389;
        #TCP traffic will be forwarded
        proxy_pass <IP_or_domain>:3389;
    }

    server {
        listen     33445;
        #TCP traffic will be forwarded
        proxy_pass <IP_or_domain>:43334;
    }

    server {
        listen     33445 udp;
        #UDP main tox traffic
        proxy_pass <IP_or_domain>:43334;
    }
}

Be sure it's outside of the top-level http { ... } block.