登录应用程序时正在更改主机名称

时间:2016-07-20 18:08:25

标签: apache ssl grails spring-security

我有一个使用spring安全插件的grails应用程序。该应用程序托管在Tomcat中,面向HTTPD。我使用以下设置强制使用HTTPS:

Tomcat中的server.xml

<Valve
   className="org.apache.catalina.valves.RemoteIpValve"
   internalProxies=".*"
   protocolHeader="X-Forwarded-Proto"
   httpsServerPort="443"
   />

httpd.conf (强制使用HTTPS)

<Location /myapp>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/?(.*) https://my.server.com/myapp [R,L]
</Location>

ssl.conf

<Location /myapp>
ProxyPass http://localhost:9090/myapp
ProxyPassReverse http://localhost:9090/myapp
        RequestHeader unset X-Forwarded-Proto
        RequestHeader add X-Forwarded-Proto "https"
</Location>

Spring安全设置

grails.plugin.springsecurity.secureChannel.definition = [ '/**': 'REQUIRES_SECURE_CHANNEL' ]
grails.plugin.springsecurity.secureChannel.useHeaderCheckChannelSecurity = true
grails.plugin.springsecurity.auth.forceHttps = 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'

问题

我可以通过http://my.server.com/myapp访问该网站(重定向到HTTPS)。但问题是,当我尝试登录时 - 提交用户名/密码并单击“提交”后,我将被重定向到:https://localhost/myapp/login/authfail?login_error=1(请注意主机名已从my.server.com更改为{{1} })。这在成功或不成功登录时发生。

同样的问题也发生在localhost上。点击logout即可转到https://my.server.com/myapp/logout

以下是跟踪网络电话的屏幕截图

enter image description here

0 个答案:

没有答案