【发布时间】:2018-09-23 13:00:53
【问题描述】:
亲爱的,
我正在尝试从 APACHE 服务器执行 php curl 调用,但我需要指定请求只能从特定端口(出站)发出。
或者至少知道 Apache 使用的传出端口的范围。因为目标服务器位于严格的防火墙后面,只允许一个 IP 和一个特定端口通过。
感谢您的帮助。
【问题讨论】:
标签: php curl networking port firewall
亲爱的,
我正在尝试从 APACHE 服务器执行 php curl 调用,但我需要指定请求只能从特定端口(出站)发出。
或者至少知道 Apache 使用的传出端口的范围。因为目标服务器位于严格的防火墙后面,只允许一个 IP 和一个特定端口通过。
感谢您的帮助。
【问题讨论】:
标签: php curl networking port firewall
你可以试试这个。 我认为这个选项 CURLOPT_LOCALPORT 是你正在寻找的
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com/");
curl_setopt($ch, CURLOPT_PORT, [destinationport]);
curl_setopt($ch, CURLOPT_LOCALPORT, [sourceport]);
$output = curl_exec($ch);
curl_close($ch);
print($output);
【讨论】: