You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dan <dm...@tsiware.com> on 2005/03/25 05:36:17 UTC
Answer: Tomcat5 port redirect issue
I figured I would post this in answer to my own question, just in case anyone
else has the same problem.
The issue was I two boxes set up one had apache, and tomcat on it, the other
just had tomcat.
The box with apache, and tomcat had tomcat running something unrelated to the
secondary box. What I wanted to do was if a particular context was requested
from the apache/tomcat domain to redirect to the other domain and to the
appropriate ports (ie 8080/8443) the redirect was simple enough, with a
rewrite rule in the apache configuration.
RewriteRule "^/({specific context})(.*)" "http://{domain of tomcat
box}/$1" [R]
for {specific context} you would substitute the context you wish to map to the
URL on the other domain.
for {domain of tomcat box} substitute the domain of the box you wish to
redirect to, from the apache box.
this was straight forward enough the trick was to redirect traffic on the
other box from port 80 to 8080 and port 443 to 8443.
I found these easiest way to do this is by adding iptable rules on the tomcat
box.
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8443
iptables -t nat -I OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -I OUTPUT -p tcp --dport 443 -j REDIRECT --to-ports 8443
the first 2 rules redirect external incoming requests, and the next 2 redirect
localhost requests. (the second isn't always necessary, but in this case it
was appropriate.)
I hope this helps someone else out of the mess of sorting this sort of thing
out.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org