如何在代理后面配置 Spring HATEOAS? [英] How to configure Spring HATEOAS behind proxy?
问题描述
我有 Spring Data Rest 和 Hateoas 作为我的支持.它位于代理后面.
I have Spring Data Rest with Hateoas as my backed. It is behind a proxy.
后端网址:backend.com
代理网址:proxy.com
当我查询代理网址时,例如http://proxy.com/items/1
,我收到一个带有 href
链接的响应,其中包含域 backend.com
.我需要域为 proxy.com
.
When I query proxy url, e.g. http://proxy.com/items/1
, I get a response with href
links with domain backend.com
. I need the domain to be proxy.com
.
推荐答案
确保您的代理将 X-Forwarded-Host: proxy.com
标头添加到 请求传递给 backend.com
.然后 Spring Hateoas 将自动生成带有 proxy.com
的链接 href.
Make sure your proxy is adding X-Forwarded-Host: proxy.com
header to the request that is passed to backend.com
. Then Spring Hateoas will automatically generate link hrefs with proxy.com
.
X-Forwarded-Host
可以包含端口.
另请参阅其他 X-Forwarded-* 标头,它们也受支持.
Also see other X-Forwarded-* headers, which are supported too.
这篇关于如何在代理后面配置 Spring HATEOAS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!