如何在代理后面配置Spring HATEOAS? [英] How to configure Spring HATEOAS behind proxy?
问题描述
我有支持Hateoas的Spring Data Rest.它在代理后面.
I have Spring Data Rest with Hateoas as my backed. It is behind a proxy.
后端网址:backend.com
代理网址:proxy.com
当我查询代理网址时,例如http://proxy.com/items/1
,我收到域为backend.com
的href
链接的响应.我需要的域名是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- *标头.
这篇关于如何在代理后面配置Spring HATEOAS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!