在 payara 上将 http 重定向到 https

Redirect http to https on payara

有人可以告诉我如何在 payara 5 上将 http 重定向到 https

我在应用级别 web.xml 和域级别的默认 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>

您还需要设置重定向端口:https://docs.oracle.com/cd/E26576_01/doc.312/e24938/create-http-redirect.htm#GSRFM00031。在默认的 http 侦听器中,端口应已设置为 HTTPS 侦听器的端口。如果您使用自定义侦听器,请确保将重定向端口设置为 HTTPS 端口。如果您的 Payara Server 在代理后面运行,您需要将重定向端口设置为代理侦听的 HTTPS 端口,很可能是标准端口 443。