使用 AWS Lambda 创建代理解决方案

Create proxy solution using AWS Lambda

我有一个案例,我想删除请求中的 cookie 并将请求发送到另一台服务器并向最终用户显示响应。

示例: client -> x.website.com -> remove cookie -> y.website.com

当前解决方案: client -> x.website.com -> ec2 instance, nginx proxy, remove cookie -> y.website.com

我想删除中间的 ec2 实例,因为它很昂贵。

有什么方法可以使用 AWS 资源实现吗?

您是否已尝试实施某些内容?

可能有效:

[Request]
client -> API Gateway -> AWS Lambda(Forward the Request) -> y.website.com

[Response]
client <- API Gateway <- AWS Lambda(Response) <- y.website.com

https://aws.amazon.com/api-gateway/details

https://aws.amazon.com/lambda/details

有多种解决方案可以解决您的用例,并按顺序推荐。

  1. 使用 AWS CloudFront as a proxy where you can you can add the y.website.com as a origin and also configure not to forward the cookies.
  2. 使用AWS API Gateway & Mapping templates只映射除cookie头之外的其他头,并代理y.website.com。
  3. 使用API网关和Lambda Proxy需要写代码排除header,转发请求到y.website.com.