如何在代理后面配置Spring HATEOAS? [英] How to configure Spring HATEOAS behind proxy?

查看:118
本文介绍了如何在代理后面配置Spring HATEOAS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有支持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.comhref链接的响应.我需要的域名是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆