7

I have setup a reverse proxy for the website, and now I want to proxy my game server aswell with the ports stated below, but I realy can't find anywhere how to perform this. Does anyone have an idea? I would like to do this if possible on apache. Am running on ubuntu.

RDP

TCP Port: 3389

MSSQL

TCP Port: 1143

TEAMSPEAK

UDP Port: 9987 TCP Port: 9987 TCP Port: 10011 TCP Port: 30033

LOGIN SERVER

TCP Port: 15001 TCP Port: 15100

GAMESERVER

TCP Port: 15221

FTP

21

FlikFlak
  • 187
  • 2
  • 2
  • 9
  • Are you looking for what: forward proxy (which Nginx is not designed for) or TCP reverse proxy (stream module)? Maybe you just need a port forwarding? – Anatoly Sep 16 '15 at 22:26

1 Answers1

5

Apache is not an ideal tool for proxying TCP connections. Nginx plus can do it but it's not free.

What you want is a proxy server like squid which is very well documented.

You can also do this without extra software, just with IP tables as explained here.

iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination ip:port
iptables -t nat -A PREROUTING -p tcp --dport 1112 -j DNAT --to-destination ip:port
iptables -t nat -A PREROUTING -p tcp --dport 1113 -j DNAT --to-destination ip:port
iptables -t nat -A POSTROUTING -j MASQUERADE
Christian
  • 582
  • 9
  • 21
  • 2
    Stream module is not Plus exclusive feature, it is available in open source version as well: http://nginx.org/en/docs/stream/ngx_stream_core_module.html – Anatoly Dec 12 '15 at 16:38
  • I just wanted to add that in addition to adding the iptables rules described here, you may also need to enable IP forwarding. To check if IP forwarding is enabled, run `sysctl net.ipv4.ip_forward`, which returns 0 if disabled, 1 if enabled. You can enable it with `sudo sysctl -w net.ipv4.ip_forward=1`, and you can edit /etc/sysctl.conf if you want this to persist across reboots. See https://fabianlee.org/2018/09/17/ubuntu-using-iptables-to-forward-tcp-and-udp-requests/ for more info. – Richard Xia Jul 11 '21 at 01:56
  • But using nginx can you run a website and this proxypass stream both on port 443 for instance? – Steve Moretz Jan 02 '23 at 07:55