0

Situation:

  • My client has a Java web application deployed on a JBoss server, it is accessed both via HTTPS and HTTP
  • The JBoss server is sitting behind a load-balancer that handles the SSL, in other words this load-balancer terminates SSL and sends requests to JBoss as plain HTTP

Problem I need to solve:

The web application deployed on JBoss needs to know what port the load-balancer is using for HTTPS, so that it can direct users to certain HTTPS urls correctly. This cannot be hard-coded because the application will be deployed on multiple clients, each of them have different configurations for the load-balancer.

My approach (which didn't work):

I am defining the port from a jspx page, via ${pageContext.request.serverPort}, but this always returns the port for HTTP because JBoss always gets the request via HTTP.

Thanks in advance. I've looked at this question but was not helpful.

Community
  • 1
  • 1
Joel Min
  • 3,387
  • 3
  • 19
  • 38
  • 1
    Use urls of the form `://` (without a protocol or port) and the client will preserve the current protocol and port. – Elliott Frisch Feb 29 '16 at 06:23
  • Hey @ElliottFrisch, it doesn't make sense for me to not include a protocol because I need to explicitly direct users to a url with https protocol (normally the website is accessed via http). Thanks! – Joel Min Feb 29 '16 at 06:27
  • 1
    In links on pages the `://` trick works (i.e. http and https will continue to function), as for redirecting certain urls that sounds like something you could extract to configuration. – Elliott Frisch Feb 29 '16 at 06:29
  • 1
    If you aren't using port 443 for HTTPS you should be. In which case you can omit it altogether. – user207421 Feb 29 '16 at 08:00
  • Cheers guys, I guess I'll have to setup a property for the clients to configure according to their needs. Thanks for the help! – Joel Min Feb 29 '16 at 22:27

1 Answers1

2

There isn't really a way to determine the port if tomcat is sitting behind a load balancer. As suggested in the comments, exposing the port configuration to your clients would be the best for now.