通过服务器/代理通 [英] Pass through server / proxy

查看:157
本文介绍了通过服务器/代理通的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找咨询如何可以做到这一点。我想有一台服务器在客户端和实际的服务器之间坐英寸例如:

I'm looking for advice on how this can be done. I want to have a server sit in between the client and the actual server. For example:

Client -> Proxy Type Server -> Web Server.

因此​​,在返回的web服务器将结果传递到回报得到的结果返回给客户机代理服务器。例如:

So in return the web server would pass results to the proxy server which in return give the results back to the client. For example:

Client <- Proxy Type Server <- Web Server

下面是一个图,如果它使生活更轻松:

Here is a diagram if it makes life easier:

如果这只是简单的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. I hope someone can advise me on this. Thank you if you can!

推荐答案

我不知道你的问题是什么?如果您设置客户端和应用服务器之间的代理服务器,那么这将是这一点:代理服务器。因此,将应用程序服务器的代理请求,就像您在图中所展示的。如果客户端 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;

这篇关于通过服务器/代理通的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆