http - 如何使用 glassfish v4 将 http 重定向到 https

标签 http redirect https glassfish

我们在 Glassfish v4 上创建了一个网站,它使用 8080 端口作为 http,8081 端口作为 https。我们的cisco防火墙将80端口的请求转发到8080端口,443端口的请求转发到8081端口。

但是我们根本不希望用户能够访问http站点。我们希望将所有对 http 站点的请求重定向到 https。如何做呢? 在 Glassfish 管理面板中,我们对 Configurations -> server-config -> Network Listeners -> http-listener-1 和 http-listener-2 进行了更改,以重定向到 HTTP 选项卡下的端口 8081,但它不起作用。 用户仍然可以从外部看到 http 站点。 谢谢你的帮助。

enter image description here

最佳答案

打开war文件WEB-INF里面的web.xml。在 <web-app> 中添加以下代码行标签。

<web-app>
  ...
    <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>
</web-app>

另见 The Java EE 6 Tutorial了解更多信息。

关于http - 如何使用 glassfish v4 将 http 重定向到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22382585/

相关文章:

java - 使用 HTTPS 的基本身份验证

Python 请求模块卡在套接字连接上,但 cURL 有效

Apache 2 : redirect to an IP address (container's address) accoring to the url

ssl - CXF RESTful 客户端

security - 当IE提示 “Only secure content is displayed”时,我能知道不安全内容的网址吗?

php - 如何从 kohana 中的 View 重定向

security - 从 EJB 调用 HTTP 时如何传播 WebSphere 安全 token

android - 如何从 picasso 的缓存中检索图像?

php - 如何将 HTTP header /正文与 PHP 套接字请求隔离开来

php - 为什么不能重定向到某些网址?