且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过服务器/代理通

更新时间:2023-09-18 23:33:10

我不知道你的问题是什么?如果您设置客户端和应用服务器之间的代理服务器,那么这将是这一点:代理服务器。因此,将应用程序服务器的代理请求,就像您在图中所展示的。如果客户端 POST s的数据给代理,代理服务器将 POST 相同的数据到应用服务器和返回响应于客户端...

I'm not sure what your question is... If you set up a proxy server between your client and the application server, then it will be just that: a proxy server. So it will proxy requests to the application server, just as you've shown in your diagram. If a client POSTs data to the proxy, the proxy server will POST that same data to the application server and return the response to the client...

你问的如何的设置是这样的?

Are you asking how to set up something like this?

编辑:我要在这里乘坐胡乱猜测......

I'm going to take a wild guess here...

如果这只是简单的GET请求不是一个问题,但我不知道,如果客户端已发布的数据将如何工作。

If it was just simple GET requests not a problem but I'm not sure how it would work if the client was posting data

你的意思是客户端 POST ING来的代理服务器在PHP或Ruby脚本的,而不是实际的代理服务器像鱿鱼或Apache的的mod_proxy ?如果是这样,你问如何使用PHP,到POST数据发送到应用程序服务器?如果这是你的问题,这里的答案是:

Do you mean that the client is POSTing to a PHP or Ruby script on the "Proxy Server", and not an actual proxy server like Squid or Apache's mod_proxy? If so, are you asking how, using PHP, to send that POST data to the application server? If that's your question, here's the answer:

<?php

$application_server = '1.2.3.4'; // replace with IP or hostname of application server
$uri = $_SERVER['REQUEST_URI']; // you may need to change this, not sure from your question.

$curl = curl_init("http://{$application_server}{$uri}");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl,CURLOPT_POSTFIELDS,$_POST);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

$data = curl_exec($curl);

// do something with $data, transform it however you want...

echo $data;