Search code examples
httpspayarapayara-micro

Redirect http to https on payara


Could someone please tell me how to redirect http to https on payara 5

I tried below code on both web.xml at app level and default-web.xml at domain level yet it's not redirecting.

<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>

Solution

  • You also need to set the redirect port: https://docs.oracle.com/cd/E26576_01/doc.312/e24938/create-http-redirect.htm#GSRFM00031. In the default http listener, the port should be laready set to the port of the HTTPS listener. If you use a custom listener, ensure that the redirect port is set to the HTTPS port. If your Payara Server runs behind a proxy, you need to set the redirect port to the HTTPS port that proxy listens on, most probably the standard port 443.