Sunday, April 24, 2011

Proxy Error (502) caused by Tomcat Http Proxy Setting When Using Struts2

In Tomcat (my version is 5.5 +), the default http port is 8080. In your server.xml connector setting, you may have the following line:

The default Catalina connetor setting for HTTP proxy is pointing to port 80.
By doing so, the HttpRequest Object resides in your session will contain two port values:
  • port=8080
  • proxy port = 80
. This may cause problem when Struts2 is in use. If you use Struts2 UrlHelper to generate the current request URL (which you may save the url as last saved location) the url generated will not contain the 8080 port because proxy port is 80 and Struts use the HttpServletRequest.getServerPort() method to get the request port. So if your url was
http://mydomain.com:8080/some.action
The generated url is actually
http://mydomain.com/some.action
If you didn't setup your web server right or you don't have one, the request is going to failed for a 502 (bad gateway) error.
So double check your sever.xml connector setting in Tomcat if you are getting a 502 error.
The simple solution here is to change proxyPort to 8080 (same as your application port).


8 comments :

  1. Your security is ensured when you utilize such intermediaries.free mexico proxy

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. If your VPN can allow you to select the authentication key size,https://novavpn.com/blog/yify/ then, you should select a smaller authentication key size to speed up your VPN connection.

    ReplyDelete
  4. There are a lot of blogs and articles out there on this topic, but you have acquired another side of the subject. This is reliable content thank you for sharing it. vpnveteran

    ReplyDelete
  5. Thank you very much for this great post. I read that Post and got it fine and informative. Please share more like that. visita il sito

    ReplyDelete