Http-redirect not works

http://unitag.asbu.edu.tr/ --X–> https://unitag.asbu.edu.tr/

“http redirect to https” doesn’t work. please help me!

I’ve added following lines to default-web.xml

   <security-constraint>
		<web-resource-collection>
			<web-resource-name>Viewpoint Secure URLs</web-resource-name>
			<url-pattern>/*</url-pattern>
		</web-resource-collection>
		<user-data-constraint>
			<transport-guarantee>CONFIDENTIAL</transport-guarantee>
		</user-data-constraint>
	</security-constraint>

then, I have executed following commands.

asadmin create-protocol --securityenabled=false http-redirect

asadmin create-http-redirect --redirect-port 8181 --secure-redirect true http-redirect

asadmin create-protocol --securityenabled=false portunif-protocol

asadmin create-protocol-filter --protocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpRedirectFilter redirect-filter

asadmin create-protocol-finder --protocol portunif-protocol --targetprotocol http-listener-2 --classname org.glassfish.grizzly.config.portunif.HttpProtocolFinder http-finder

asadmin create-protocol-finder --protocol portunif-protocol --targetprotocol http-redirect --classname org.glassfish.grizzly.config.portunif.HttpProtocolFinder http-redirect

asadmin set configs.config.server-config.network-config.network-listeners.network-listener.http-listener-1.protocol=portunif-protocol

then following lines was added to domain.xml

          <protocol name="http-redirect">
            <http-redirect port="8181" secure="true"></http-redirect>
            <protocol-chain-instance-handler>
              <protocol-chain>
                <protocol-filter classname="org.glassfish.grizzly.config.portunif.HttpRedirectFilter" name="redirect-filter"></protocol-filter>
              </protocol-chain>
            </protocol-chain-instance-handler>
          </protocol>
          <protocol name="portunif-protocol">
            <port-unification>
              <protocol-finder protocol="http-listener-2" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-finder"></protocol-finder>
              <protocol-finder protocol="http-redirect" classname="org.glassfish.grizzly.config.portunif.HttpProtocolFinder" name="http-redirect"></protocol-finder>
            </port-unification>
          </protocol>
        </protocols>
        <network-listeners>
          <network-listener protocol="portunif-protocol" port="8585" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp"></network-listener>
          <network-listener protocol="http-listener-2" port="8181" name="http-listener-2" thread-pool="http-thread-pool" transport="tcp"></network-listener>
          <network-listener protocol="pu-protocol" port="4848" name="admin-listener" thread-pool="admin-thread-pool" transport="tcp"></network-listener>
        </network-listeners>

Hi @gokhanersoy,

Using the latest version of Payara Community Edition, 5.2022.2, I was able to configure a simple servlet at localhost:8080/hello. I then added the snippet you gave to my web.xml file and ran the asadmin commands you listed. I made no manual changes to the domain.xml.

When I navigated to localhost:8080/hello again, I was redirected to localhost:8181/hello as expected. Does http redirect work as you expect if you make no manual changes to the domain.xml and use the latest version of Payara Community Edition?

Thanks,
James