Grails Spring Security secureChannel不重定向https?

我目前有一个我正在使用的应用程序,我在云端使用(Jelastic).我已将SSL证书添加到我的云环境中,并希望能够在某些页面上使用https.我已经实现了以下方法:

方法1:

grails.plugins.springsecurity.secureChannel.definition = [
   '/login/**':         'REQUIRES_SECURE_CHANNEL'
]

方法2:

grails.plugins.springsecurity.secureChannel.definition = [
   '/login/**':         'REQUIRES_SECURE_CHANNEL'
]

grails.plugins.springsecurity.secureChannel.useHeaderCheckChannelSecurity = true
grails.plugins.springsecurity.secureChannel.secureHeaderName = 'X-Forwarded-Proto'
grails.plugins.springsecurity.secureChannel.secureHeaderValue = 'http'
grails.plugins.springsecurity.secureChannel.insecureHeaderName = 'X-Forwarded-Proto'
grails.plugins.springsecurity.secureChannel.insecureHeaderValue = 'https'

因此,对于方法1,它部分工作,当您在HTTP中转到索引页面然后尝试转到登录页面时,您将看到一条错误消息:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

然而,方法2似乎根本不起作用,当我进入HTTP上的登录页面时,它不会像我期望的那样重定向我,而且似乎只能在HTTP上工作,这很奇怪.

我提到这个解决方案是在Jelastic中提供的,所以不确定是否会导致一些问题,但提供的任何帮助都会很棒.

提前致谢

最佳答案 我使用以下配置部署到prod服务器.然后它开始在https上.我使用的是jdk 1.8和Tomcat 8.

grails.plugin.springsecurity.portMapper.httpPort = 80
grails.plugin.springsecurity.portMapper.httpsPort = 443
grails.plugin.springsecurity.secureChannel.secureHeaderName = 'X-FORWARDED-PROTO'
grails.plugin.springsecurity.secureChannel.secureHeaderValue = 'http'
grails.plugin.springsecurity.secureChannel.insecureHeaderName = 'X-FORWARDED-PROTO'
grails.plugin.springsecurity.secureChannel.insecureHeaderValue = 'https'
grails.plugin.springsecurity.auth.forceHttps = true
grails.plugin.springsecurity.secureChannel.definition = [
        '/**':               'REQUIRES_SECURE_CHANNEL'
]
点赞