首页 > 编程语言 > 详细

spring cloud gateway和nigix 路由转发时携带域名头信息

时间:2021-05-18 15:40:20      阅读:13      评论:0      收藏:0      [点我收藏+]

1.nigin添加一段配置

  server {
        listen 80; 
        # this is the key !!!!! 
        proxy_set_header Host $host;
        location /client/pids {
            proxy_pass http://10.103.13.103:3200/client/pids;
        }
        location /interface/client/pids {
            proxy_pass http://10.103.13.103:3200/interface/client/pids;
        }
        ......

2.gateway网关配置

有一个过滤器PreserveHostHeaderGatewayFilter,用来在gateway转发请求的时候把原始请求的host头部带上,转发给目标服务。

- id: auth-service
uri: lb://auth-service
predicates:
- Path=/api/auth/**,/api/oauth/dd/**
filters:
- StripPrefix=1
- PreserveHostHeader #发送网关原始主机头:

转自:https://www.cnblogs.com/abu1314/articles/13123654.html

spring cloud gateway和nigix 路由转发时携带域名头信息

原文:https://www.cnblogs.com/duanxz/p/14780228.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!