我尝试将以下内容放在我的web.conf中
<security-constraint>
<web-resource-collection>
<web-resource-name>SecureResource</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
但是,当我发布时,在chrome上显示“重定向过多”。
我假设您在AWS上的负载均衡器后面运行Glassfish,并且SSL终止发生在负载均衡器上。
您需要配置Glassfish来检查x-forwarded-proto
标头,以确定客户端是通过HTTP还是HTTPS连接。 您可以通过domain.xml
文件中的scheme-mapping参数来执行此操作:
<http default-virtual-server="server"
max-connections="100"
scheme-mapping="X-Forwarded-Proto">
或者,您可以在服务器上运行此命令来设置scheme-mapping
值:
asadmin set server.network-config.protocols.protocol.http-listener-1.http.scheme-mapping=X-Forwarded-Proto