简体   繁体   English

PHP / Curl:通过中间服务器访问外部Web API

[英]PHP/Curl: Accessing an external web API through an intermediate server

I have a server that accesses an external API not from our company via HTTP GET. 我有一台服务器通过HTTP GET访问不是来自我们公司的外部API。 It can only be accessed from the IP address of the registered server A. 只能从注册服务器A的IP地址访问它。

I now need some of the information from that API on a second server B. However, using PHP+Curl it does take quite long to send a request from server A to server B that then forwards it to the API and all the way back. 现在,我需要第二个服务器B上该API的一些信息。但是,使用PHP + Curl确实需要很长时间才能将请求从服务器A发送到服务器B,然后再将其转发到API并一直返回。

How can I speed things up? 我如何加快速度?

System: Ubuntu 10.10 / server A and B are with the same hosting company / PHP is used with MySQL / programming something in C would be an option 系统:Ubuntu 10.10 /服务器A和B与同一托管公司/ PHP与MySQL一起使用/使用C语言进行编程是一种选择

You should use a web server on Server A to act as a reverse proxy for the external API (With access only from Server B) and they access the API as if it was accessible on Server A. 您应该在服务器A上使用Web服务器充当外部API的反向代理(仅可以从服务器B进行访问),并且它们就像在服务器A上可以访问一样访问API。

There is a tutorial on how to configure reverse proxies in apache on Apache Tutor . 一个关于如何在Apache Tutor上的apache中配置反向代理的教程

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

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