Im running a tomcat in port 80 without httpd
I want redirect packages from 80 to 8080 because tomcat is running as
tomcat user (cant run as other non root under port 1025) and I tried the
IPTABLES redirection aproach but doesnt work

I performed the same setup to have tomcat running on 8080 but users
connecting on port 80. The following should work:

# Forward request from port 80 to tomcat listening on port 8080
# REDIRECT is a specialized case of Destination NAT: it is exactly
equivalent to doing DNAT to the address of the incoming interface.
# as with DNAT, it can be used only in PREROUTING and OUTPUT
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

# PREROUTING happens before INPUT, therefore the INPUT rule needs to
allow the translated packet, not the original one.
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

Regards,

Gaël

Reply via email to