问题描述
试图从 spring-boot 应用程序调用 AWS vpc 端点。Vpc 端点是开放的并且没有任何授权,对于 FeignClient 我有 403 Forbidden 响应。我检查了网址 - 一切正常,还尝试添加用户代理标头,但不幸的是我仍然有 403 响应 2 个端点。
这是我的 FeignClien:
@FeignClient(name = "pam",url = "${pam.client.base-url}")
public interface PamClient {
@RequestMapping(method = RequestMethod.GET,value = "/principals/{principalId}",headers = {"host=${pam.client.host}"})
@FeignErrorHandler(PamClientExceptionHandler.class)
PrincipalResponse getPrincipal(@PathVariable Integer principalId);
@GetMapping(value = "/accounts/{accountId}",headers = "Host=${pam.client.host}")
@FeignErrorHandler(PamClientExceptionHandler.class)
AccountResponse getAccount(@PathVariable Integer accountId);
}
FeignClient 的属性:
pam.client.base-url=https://vpce-02c2052bb9bf81b7b-kvpypnmg.execute-api.us-east-1.vpce.amazonaws.com/qa
pam.client.host=hncvxm9lwi.execute-api.us-east-1.amazonaws.com
当我尝试用 Unirest 调用这个 api 时,一切都很好,我得到了正确的响应,状态为 200
return Unirest.get("https://vpce-02c2052bb9bf81b7b-kvpypnmg.execute-api.us-east-1.vpce.amazonaws.com/qa/principals/134")
.header("host","hncvxm9lwi.execute-api.us-east-1.amazonaws.com")
.asstring();
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)