We are trying to get our webapp to run on 3 Glassfish servers that are behind a load balancer. The load balancer is handling the SSL traffic and off loading the request to port 80 on the Glassfish servers. However, when Glassfish executes a redirect (even if the redirect is a relative URL) it is re-writing the URL and replacing the HTTPS with HTTP. Is there any way to stop this from happening?
here is a mock example of what is happening:
- request to https://www.glassfishserver.com
- redirect is issued to https://www.glassfishserver.com/webapp
- Glassfish then re-writes it and send the redirect to the client as http://www.glassfishserver.com/webapp
Any help would be appreciated.
Hi,
You do not need to redirect to https location in GlassFish. Just redirect to http://www.glassfishserver.com/webapp in GlassFish. The load-balancer plugin will take care of converting http to https. This is based on rewrite-location being set to true(default setting) in load-balancer xml. Refer to document : http://docs.sun.com/app/docs/doc/821-0182/gbwwx?l=en&a=view
Kshitiz
We aren't using the Glassfish Load Balancing plugin. We have an external load balancer that is handing off the traffic to Glassfish.
In such a case, you need a mechanism to indicate to GlassFish that original request was over SSL. Your external load-balancer must add some headers to proxied request to indicate that. Then you need to provide implementation of ProxyHandler and set it in GlassFish which handles parsing of headers added by external load-balancer and set values appropriately on HTTP request. Take a look at default implementation of ProxyHandler, i.e. com.sun.enterprise.web.ProxyHandlerImpl, in GlassFish.
Kshitiz