PHP安全远程代理服务器健康

时间:2009-04-21 13:07:58

标签: php proxy security

希望在安全的远程代理服务器停止工作时收到警报;例如,如果Apache出于某种原因挂起。

由于远程机器仍然启动,仍然可以ping,但这可能会很少。

需要能够编写通过代理请求路径的内容,然后返回结果。

调查了PHP / PEAR Net library,认为Net_traceroute()之类的东西可能是一个起点,但无法弄清楚如何强制通过服务器的路由。

有什么想法吗?我是应该使用PHP还是其他语言让这更容易?

干杯,

AJ

1 个答案:

答案 0 :(得分:1)

如果你想通过代理发出HTTP请求,我想是因为你提到Apache作为代理?,那么你可以使用cURL。可能是这样的:

<?php
$curl = curl_init('http://www.example.com');

//don't fetch the actual page, you only want to check the connection is ok
curl_setopt($curl, CURLOPT_NOBODY, true);

//stop it from outputting stuff to stdout
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

//proxy settings
curl_setopt($curl, CURLOPT_PROXYPORT, 8080);
curl_setopt($curl, CURLOPT_PROXY, 'proxyhost');
curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'user:password');

$result = curl_exec($curl);

if ($result === false) {
    die (curl_error($curl)); 
}  

cURL记录here还有更多选项。

相关问题