gpt4 book ai didi

spring-cloud - Spring Cloud Gateway - 基于头的重定向

转载 作者:行者123 更新时间:2023-12-03 21:23:22 29 4
gpt4 key购买 nike

仅使用 Spring Cloud Gateway,我目前正在使用以下路由(在 Kotlin 中定义)代理远程站点:

@GetMapping("/proxgoo/**")
@Throws(Exception::class)
fun proxyPath(proxy: ProxyExchange<*>): ResponseEntity<*> {
val path = proxy.path("/proxgoo/")
return proxy.uri(proxiedRemote.toString() + "/" + path).get()
}

这很好用。如果我们设置 proxiedRemotehttps://www.google.com ,这很好用,直到我们尝试加载外部资源(如图像)。

问题是这样的:
http://localhost:8081/logos/doodles/2018/**
真的应该出去:
http://localhost:8081/proxgoo/logos/doodles/2018/**
我在想,如果我可以重定向所有内容, 推荐人 标题是 http://localhost:8081/proxgoo/回到代理路由,然后这就是我所需要的:

所以,实际问题。我认为以下配置将使用请求 header 重定向所有内容推荐人 = http://localhost:8081/proxgoo/ ,但它没有捡起来。我做了什么傻事吗?
spring:
cloud:
gateway:
routes:
- id: redirect_on_referer
predicates:
- Header=Referer,http://localhost:8081/proxgoo/
filters:
- RedirectTo=302, http://localhost:8081/proxgoo/

最佳答案

这下routes应该让你去那里:

- id: redirect_on_referer
uri: http://localhost:8081
predicates:
- Header=Referer, http://localhost:8081/proxgoo/
filters:
- RewritePath=/(?<segment>.*), /proxgoo/$\{segment}

关于spring-cloud - Spring Cloud Gateway - 基于头的重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50099185/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com