Activities

November 2012
M T W T F S S
« Oct   Dec »
 1234
567891011
12131415161718
19202122232425
2627282930  

Glassfish 3 :- Force redirect all the http requests to https

While I’ve been migrating one jsf2 application to the latest version Glassfish3, I need forcefully re-direct all the http requests to https. It’s easy to achieve the same(ie force to https) very easily on earlier Glassfish version which can be done it by simply put a tick on the “SSL enabled” option under “http-lister-1”.

But the Glassfish Ver3 does not support this option and re-direct won’t be happen even the check box is enabled. Oracle has hidden some options in admin window for community version I believe. I found http://antwerkz.com/port-unification-in-glassfish-3-part-1/ is very useful.

Here are the steps to make this,

I’ve created a domain ‘domain1” for my application.

[root@web03 ~]# cd /var/glassfish/domains/domain1/config
[root@web03 ~]#asadmin create-protocol --securityenabled=false http-redirect
[root@web03 ~]#asadmin create-protocol-filter --protocol http-redirect --classname com.sun.grizzly.config.HttpRedirectFilter redirect-filter

[root@web03 ~]#asadmin create-protocol --securityenabled=false pu-protocol
[root@web03 ~]#asadmin create-protocol-finder --protocol pu-protocol --targetprotocol http-listener-2 --classname com.sun.grizzly.config.HttpProtocolFinder http-finder
[root@web03 ~]#asadmin create-protocol-finder --protocol pu-protocol --targetprotocol http-redirect --classname com.sun.grizzly.config.HttpProtocolFinder http-redirect
[root@web03 ~]#asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol=pu-protocol

2 comments to Glassfish 3 :- Force redirect all the http requests to https

  • ahmed sherif

    it wroked great on glassfish 3
    it’s not working for glassfish 4
    even after i update the commands withe the new class names

    org.glassfish.grizzly.config.portunif.HttpRedirectFilter
    org.glassfish.grizzly.config.portunif.HttpProtocolFinder

    please help me

    • Sorry. I had n’t get an opportunity to meet this error as still I’m using GF3 currently. But sure Oracle does not provide advanced support/GUI config. to set this on community edition even though it’s possible to enable. Most of the options are hide on their community distribution.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>