简体   繁体   English

在AWS中设置代理以向客户端请求添加简单的HTTP标头

[英]Setting up a proxy in AWS that adds a simple HTTP header to client requests

I would want to set up a simple proxy in Amazon Web Services that, in addition to acting as a proxy between the client and server, adds a simple (fixed) HTTP header to every client request before sending them to server. 我想在Amazon Web Services中设置一个简单的代理,该代理除了充当客户端和服务器之间的代理外,还向每个客户端请求添加一个简单的(固定的)HTTP标头,然后再将它们发送到服务器。

I already looked at the most promising http://aws.amazon.com/cloudfront which, however, doesn't seem to allow adding headers. 我已经看过最有前途的http://aws.amazon.com/cloudfront ,但是似乎不允许添加标题。 The other but rather inconvenient option would be setting up a new EC2 (or BeansTalk) service to do the proxying work, but this feels like overkill for such a simple task, and additionally would need ELB/AutoScaling setup to ensure availability. 另一个但不方便的选择是设置一个新的EC2(或BeansTalk)服务来执行代理工作,但这对这样一个简单的任务来说似乎有点过头了,而且还需要ELB / AutoScaling设置来确保可用性。

Is there any simple high-level way to get this done without falling back to setting up custom servers or services? 是否有任何简单的高级方法可以完成此任务而又不依赖于设置自定义服务器或服务?

You can deploy your own nginx instance and you can add a custom header to every request with this option: 您可以部署自己的nginx实例,并可以使用以下选项向每个请求添加自定义标头:

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header

Unfortunately Cloudfront does not support adding headers. 不幸的是,Cloudfront不支持添加标题。

I would deploy cloudfront anyway. 无论如何,我都会部署Cloudfront。 You can set the origin server as your nginx on a ec2 instance. 您可以将原始服务器设置为ec2实例上的nginx。 Data transfer between cloudfront and ec2 is free: cloudfront和ec2之间的数据传输是免费的:

With Amazon CloudFront, you can use an AWS origin (eg, Amazon S3, Amazon EC2, Elastic Load Balancing, etc.) or your own origin servers to store the original, definitive versions of your files. 借助Amazon CloudFront,您可以使用AWS原始服务器(例如Amazon S3,Amazon EC2,Elastic Load Balancing等)或您自己的原始服务器来存储文件的原始确定版本。 If you are using an AWS origin, effective December 1, 2014, data transferred from origin to edge locations (Amazon CloudFront "origin fetches") will be free of charge. 如果您使用的是2014年12月1日生效的AWS原点,则从原点传输到边缘位置的数据(Amazon CloudFront“原点获取”)将是免费的。 This applies to data transfer from all AWS regions to all global CloudFront edge locations. 这适用于从所有AWS区域到所有全局CloudFront边缘位置的数据传输。 Data Transfer out of Amazon CloudFront to your origin server will be billed at the “Regional Data Transfer Out to Origin” rates listed above. 从Amazon CloudFront到您的原始服务器的数据传输将按照上面列出的“将区域数据传输到原始服务器”的费用计费。 Pricing for all AWS services is available here. 所有AWS服务的价格均可在此处获得。

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

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