users@glassfish.java.net

Re: http redirect from 8080 to 80

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Tue, 13 Mar 2012 22:23:33 +0100

Hi Bobby,

just as alternative you may try to create listeners w/ http-redirect
protocols.
Bellow is an example how you can define a listener on port 8888, which
will redirect http traffic to port 8080 and https traffic to port 8181.

So basically we create a new network-listener, which refers pu-protocol
(port unification protocol). And define pu-protocol w/ 2 redirect
sub-protocols for http and https.
You can use similar definition to redirect 8080 traffic to 80 and 8181
to 443.

Thanks.

WBR,
Alexey.

<network-config>
<protocols>
<protocol name="http-listener-1">
<http default-virtual-server="server" max-connections="250">
<file-cache></file-cache>
</http>
</protocol>
<protocol security-enabled="true" name="http-listener-2">
<http default-virtual-server="server" max-connections="250">
<file-cache></file-cache>
</http>
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl"
cert-nickname="s1as"></ssl>
</protocol>
<protocol name="admin-listener">
<http default-virtual-server="__asadmin" max-connections="250"
encoded-slash-enabled="true">
<file-cache></file-cache>
</http>
</protocol>

*<protocol name="http-redirect">
<http-redirect secure="false" port="8080"></http-redirect>
</protocol>
<protocol name="https-redirect" security-enabled="true">
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl"
cert-nickname="s1as"></ssl>
<http-redirect secure="true" port="8181"></http-redirect>
</protocol>

<protocol name="pu-protocol">
<port-unification>
<protocol-finder protocol="http-redirect" name="http-finder"
classname="com.sun.grizzly.config.HttpProtocolFinder"></protocol-finder>
<protocol-finder protocol="https-redirect" name="https-finder"
classname="com.sun.grizzly.config.HttpProtocolFinder"></protocol-finder>
</port-unification>
</protocol>*
</protocols>

<network-listeners>
*<network-listener port="8888" protocol="pu-protocol" transport="tcp"
name="http-listener-9" thread-pool="http-thread-pool"></network-listener>*
<network-listener port="8080" protocol="http-listener-1" transport="tcp"
name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
<network-listener port="8181" protocol="http-listener-2" transport="tcp"
name="http-listener-2" thread-pool="http-thread-pool"></network-listener>
<network-listener port="4848" protocol="admin-listener" transport="tcp"
name="admin-listener" thread-pool="admin-thread-pool"></network-listener>
<network-listener port="8009" protocol="http-listener-1" transport="tcp"
name="jk-connector" jk-enabled="true"
thread-pool="jk-thread-pool"></network-listener>
</network-listeners>

On 03/13/2012 03:46 PM, forums_at_java.net wrote:
> [quote=oleksiys]Hi Bobby, which GF version are you using? [/quote]
>
> Currently 3.1.1, but I'm looking into moving to 3.1.2 because I
> discovered
> the bug in RealmAdapter that prevents redirecting from http to https when
> using default ports (works great 8080 to 8181 but not 80 to 443).
>
> Thanks, Bobby
>
>
>
>
> --
>
> [Message sent by forum member 'bbissett']
>
> View Post: http://forums.java.net/node/884215
>
>