Search code examples
apacheubuntuiptables

Persistent Port forwarding in Ubuntu


I want to forward TCP connections on server1:8082 to server2:8082. Is there a way i can make a persistent port forwarding. Apache doesnt work well with TCP. I was thinking of IPTABLES as alternative. What would be the persistent way of port forwarding TCP connections in IPTABLES.

Feel free to let me know if there are alternatives to IPTABLES and APACHE.


Solution

  • I recommend that a rewrite engine can resolve your problem.

    You can add the below at your virtualhost configuration. I assumed "server1" and "server2" are domain name for the each server.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^server1
    RewriteRule ^(.*) http://server2? [R=301,L]