简体   繁体   English

无法从EC2实例访问使用AWS API Gateway公开的Web服务。 返回403 {“message”:“Forbidden”}

[英]Webservice exposed using AWS API Gateway is not accessible from the EC2 instance. Returns 403 { “message”: “Forbidden” }

I created REST API using AWS API Gateway with following details 我使用AWS API Gateway创建了REST API,其中包含以下详细信息

  • Endpoint Type: Edge Optimized 端点类型:边缘优化
  • Integration Type: Mock 整合类型:模拟
  • The API is open with API已打开
    • Auth: None 身份验证:无
    • Api Key Required: False 需要Api密钥:错误
    • Request Validator: None 请求验证器:无
    • Resource-policy: Not defined 资源政策:未定义

I successfully deployed the API 我成功部署了API

API is accessible from the outside world/ public network API可从外部世界/公共网络访问

API is not accessible from the EC2 instance launched in same account(Not tried to access it from other AWS account). 无法从同一帐户中启动的EC2实例访问API(未尝试从其他AWS账户访问它)。 API returns with 403 { "message": "Forbidden" } API返回403 {“message”:“Forbidden”}

What I am missing here which makes the API inaccessible from EC2 ? 我在这里缺少什么使得EC2无法访问 API?

I had the same problem. 我有同样的问题。 It turned out that I had a VPC endpoint with private DNS in that VPC, see https://aws.amazon.com/ru/premiumsupport/knowledge-center/api-gateway-vpc-connections/ : 事实证明,我在该VPC中有一个带私有DNS的VPC端点,请参阅https://aws.amazon.com/ru/premiumsupport/knowledge-center/api-gateway-vpc-connections/

When you select the Enable Private DNS Name option while creating an interface VPC endpoint for API Gateway, you can access your private APIs using a private or public DNS, but you can't access your public APIs . 在为API网关创建接口VPC端点时选择“启用专用DNS名称”选项时,可以使用专用或公用DNS访问私有API, 但无法访问公共API

Can you please check if you are acessing the correct API GW Endpoint? 您能否检查一下您是否正在访问正确的API GW端点?

API GW returns 403 when you are trying to access an endpoint that doesn't exist. 当您尝试访问不存在的端点时,API GW返回403。

Also check if you have deployed your latest version. 还要检查是否已部署最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM