Grails Spring Security redirect to login page using https

后端 未结 3 1049
猫巷女王i
猫巷女王i 2021-01-02 03:53

I have a Grails app using Spring Security Core running on an AWS machine behind a load balancer.

The load balancer decrypts the ssl connections and forwards to port

3条回答
  •  情书的邮戳
    2021-01-02 04:12

    I just went through the same scenario. Got stuck on the https, then the redirects, and now all is well. Use these Config.groovy settings:

    grails.plugin.springsecurity.secureChannel.useHeaderCheckChannelSecurity = true
    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'
    

    Note for those not using springsecurity 2.0, it is 'plugins' and not 'plugin' without the 's'.

    My beanstalk load balancer settings look like this (I have an SSL cert installed, I didn't show it):

    enter image description here

    In the EC2 load balancer settings make sure your listeners are set right:

    enter image description here

    And finally in the EC2 security groups make sure the EB accepts requests on ports 80 and 443 from the ELB:

    enter image description here

    Note that nowhere in my setup of anything do I ever reference ports 8080 or 8443, even though that is what I use on my localhost for testing. Somebody reading this may think about trying to use those ports to fix the issues. My setup didn't require that.

提交回复
热议问题