我有一套Spring Boot(1.3.3),在Zuul后面运行Spring Cloud(Brixton.RC2)微服务,我的网址被重定向重写了.
我的主要问题是我的网络应用程序落后于zuul,并且在重定向期间似乎不知道主机,即使我应该设置所有必要的属性.
当我访问http://test.example.com/时,我希望被重定向到http://test.example.com/login,但我被重定向到http:// machinehostname/login ...如果我直接去到http://test.example.com/login我可以看到我的登录表单和登录但是然后被重定向到http:// machinehostname /但如果我手动转到http://test.example.com/我可以使用例如,在表单中的POST之后,我的应用程序再次正确地执行重定向.
以下是我的网络应用的一些属性:
server.use-forward-headers = true
server.tomcat.protocol-header = X-Forwarded-Proto
server.tomcat.remote-ip-header = X-Forwarded-For
Run Code Online (Sandbox Code Playgroud)
这是我的zuul属性:
#Server
server.port = 80
server.use-forward-headers = true
#Zuul
zuul.add-proxy-headers = true
zuul.ignored-services = "*"
zuul.routes.api.service-id = api
zuul.routes.api.path = /api/**
zuul.routes.api.strip-prefix = true
zuul.routes.web.service-id = web
zuul.routes.web.path = /**
Run Code Online (Sandbox Code Playgroud)
我在网络应用中的安全设置:
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
//@formatter:off
httpSecurity
.formLogin()
.successHandler(new SavedRequestAwareAuthenticationSuccessHandler())
.loginPage("/login")
.permitAll()
.failureUrl("/login-error")
.defaultSuccessUrl("/")
.and()
.logout() …Run Code Online (Sandbox Code Playgroud) spring-security spring-boot netflix-zuul spring-cloud-netflix