简体   繁体   English

从EC2访问英国API

[英]Accessing a UK API from EC2

I have a java web application running on Amazon EC2 (on a single instance, running in the Ireland EU West region), which makes HTTP requests to UK based sites and APIs (as it happens, using the Apache HttpClient). 我有一个在Amazon EC2上运行的Java Web应用程序(在单个实例中,在爱尔兰欧盟西部地区运行),该应用程序向基于英国的站点和API发出HTTP请求(实际上是使用Apache HttpClient)。
When running on a local Tomcat server here in the UK, everything works as expected, but when deployed on EC2, the application is no longer making requests from the UK, so everything breaks down (as the websites restrict access from outside the UK and the APIs return US region specific data). 当在英国的本地Tomcat服务器上运行时,一切正常,但是在EC2上部署后,该应用程序不再发出来自英国的请求,因此一切都崩溃了(因为网站限制了来自英国境外的访问,并且API返回美国地区特定的数据)。
The obvious solution seems to be to route the HTTP requests via a UK proxy server, which I'd expect would resolve the issue, but would degrade performance a little and provide an extra point of failure (eg if the proxy server were blacklisted). 显而易见的解决方案似乎是通过UK代理服务器路由HTTP请求,我希望这可以解决该问题,但是会稍微降低性能并提供额外的故障点(例如,如果将代理服务器列入黑名单)。 As it's a web application, I could also move some of the request logic out to the browser (eg through XHR GETs in Javascript), though there's a fair amount of processing to be done, and I'd rather keep the bulk of it server side. 由于它是一个Web应用程序,所以我也可以将一些请求逻辑移到浏览器中(例如,通过Javascript中的XHR GET),尽管有大量的工作要做,我宁愿将其大部分存储在服务器上侧。
Is there any way to configure EC2 or the requests to get around this issue, or is there an alternative/better solution? 有什么方法可以配置EC2或解决该问题的请求,还是有替代/更好的解决方案?

在“接受语言”标头中发送“ en-gb”可能无法正常工作,但值得尝试。

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

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