Spring Data Rest - 代理路径不包括链接路径 [英] Spring Data Rest - Proxy path not including link path
问题描述
我像这样代理 Spring REST 后端:
I'm proxying a Spring REST backend like so:
后端:http://backend:8080
代理本地主机:
localhost:3000/api/backend ->http://backend:8080
如果我在本地浏览到代理端点,它将代理请求,但是链接不包括代理路径,即
If I browse locally to a proxied endpoint, it will proxy the request, the links, however, do not include the proxy path, i.e.
GET localhost:3000/api/backend/people
"href": "http://localhost:3000/people"
我希望这是:
"href": "http://localhost:3000/api/backend/people"
有什么办法可以解决这个问题吗?
There any way to fix this?
谢谢!
推荐答案
您应该查看您的代理添加到请求中的 x-forwarded-*
标头.
You should have a look at the x-forwarded-*
headers your proxy is adding to the request.
如果从您的代理到后端的请求包含标头 x-forwarded-prefix=/api/backend
spring 将获取前缀并将其添加到生成的链接中.
If the request from your proxy to the backend contains the header x-forwarded-prefix=/api/backend
spring will pick up the prefix and add it to the generated link.
您没有提及您使用的是哪个代理,所以我无法判断您的代理是否支持添加 x-forwarded-prefix
标头.
You do not mention which proxy are you using so I cannot tell if your proxy supports adding the x-forwarded-prefix
header.
这篇关于Spring Data Rest - 代理路径不包括链接路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!