I have 2 servers running 2 instanced of Tomcat each (one Tomcat instance for RC, one for Production). These servers, let's call them server1 and server2, are set behind an F5 load balancer to maintain uptime, and to provide SSL support. When someone goes to server1:8081, they get the welcome screen for the second instance of tomcat on server1 (and server1:8080 will give the first instance). When connecting to server:8443, which the F5 load balanced URL that goes to server1:8081 and server2:8081, I will also get the Tomcat welcome screen for that instance listening on port 8081. However, when going to server:8443/app/, I get an error, and wireshark packet captures show the redirect going to server1 port 8080. I am at a loss as to where the redirect to port 8080 is coming from, and I don't have any redirects in my server.xml for that tomcat instance base configuration. Anyone have any idea if maybe during the .war file compilation, the actual app might have pulled in the port redirection?

3 Answers 3


Yes, web apps often redirect if entered url is not 100% as expected. The novice developers tend to redirect naively, that is they make application respond HTTP 302 http://my-host:8080/proper/link/index.jsp where they use a hard-coded text for 8080 (and also http but this one becomes less often a problem with redirects).

In other words, they use the redirect that works perfectly on their laptops, but miserably fails when Tomcat uses a different port. F5, like any other frontend (also known as a "reverse proxy") intercepts the HTTP redirect and if the application would use http://server1:8081/xxx your browser would receive https://server:8443/xxx. But it gets confused with 8080 and leaves it as-is.

My usual response is to file a bug to app developers: request the redirect to be made using the port number determined automatically (if tomcat listens on 8085 some day in future, the redirect should be to 8085).


I ended up getting some documentation from the app developer on setting the apps up behind a load balancer. I had to add in the proxyName and proxyPort attributes to my connector section of my server.xml file.


You can try to add RemoteIpValve to META-INF/context.xml of your webapp and it will populate request.serverPort to port of F5 and even request.remoteAddr to real IP of client instead of IP of proxy. Then you can generate any links as usual and all of them will contain hostname and port of front reverse proxy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.