spring cloud gateway和nigix 路由轉發時攜帶域名頭信息


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM