为什么zuul不会在http标头位置更改下游服务重定向IP?

时间:2017-01-06 16:37:30

标签: spring spring-cloud netflix-zuul spring-cloud-netflix

我在使用zuul的反向代理中遇到了问题。

我的应用程序有一个下游服务,它使用spring security进行身份验证。当用户请求Index.jsp。

时,此项目会重定向到login.jsp

我在zuul项目中的zuul配置是:

 zuul:
  #addProxyHeaders : true
  #ignoreSecurityHeaders: false
  routes:
    trp:
      path: /app/**
      url: http://192.168.251.141:5050/app
server:
    port: 80

但是,当用户将http://localhost/app/Index.jsp应用程序重定向调用到http://192.168.251.141:5050/app/Login.jsp

谷歌搜索后我发现响应是这样的:

Content-Encoding    gzip
Content-Type    text/html
Date     Mon, 26 Dec 2016 09:02:44 GMT
Location    http://192.168.251.141:5050/app/Login.jsp
Transfer-Encoding    chunkedVary    
Accept-Encoding  
X-Application-Context    application:80
X-Content-Type-Options    nosniff
X-Frame-Options    SAMEORIGIN
X-XSS-Protection    1; mode=block

为什么Location标题为http://192.168.251.141:5050/app/Login.jsp?为什么Zuul不改变这个ip?

此配置使用proxy_redirect模块在​​nginx中工作。如何通过zuul路线改变位置?

1 个答案:

答案 0 :(得分:0)

默认情况下,Zuul不会重写任何回复。您的下游服务必须知道如何处理zuul添加的X-Forwarded-Host标头并在那里重定向。另一种选择是编写一个重写Location头的zuul过滤器。