【问题标题】:How do I redirect https:// requests to http:// in resin4.0如何在resin4.0中将https://请求重定向到http://
【发布时间】:2012-09-13 07:18:55
【问题描述】:

事实上,我得到了将 http 重定向到 https 的方法,因为我在 web.xml 中添加了一个过滤器。 比如,

<security-constraint>
    <web-resource-collection>
        <web-resource-name>SSL</web-resource-name>
        <url-pattern>/xxx/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

在这种情况下,我可以在 https 模式下请求像 /xxx/* 这样的 URL。 还有一些其他的 url,比如/yyy/*,必须在 http 模式下请求,我该怎么做呢?

【问题讨论】:

    标签: http https openssl web.xml resin


    【解决方案1】:

    在resin-web.xml 中,您可以使用Resin rewrite 标签重定向到不同的URL 并检查IfSecure 等条件。

    例如,您的 WEB-INF/resin-web.xml 可能看起来像

    <web-app xmlns="http://caucho.com/ns/resin"
             xmlns:resin="urn:java:com.caucho.resin">
    
      <resin:Redirect regexp="^/xxx/" target="https://myhost.com/xxx/">
        <resin:IfSecure value="false"/>
      </resin:Redirect>
    
      <resin:Redirect regexp="^/yyy/" target="http://myhost.com/yyy/">
        <resin:IfSecure value="true"/>
      </resin:Redirect>
    
    </web-app>
    

    /xxx 上的第一个匹配项,并检查它是否是 SSL 连接。如果不是 SSL 连接,它将重定向到主机的 https。否则忽略该规则。

    第二个匹配您的 /yyy,并检查它是否是 SSL 连接。如果是 SSL 连接,它会重定向到您主机的 http。否则忽略该规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      • 2019-09-08
      • 1970-01-01
      • 2011-05-04
      相关资源
      最近更新 更多