与特定端口的传出连接被阻止了?

时间:2019-04-14 17:15:14

标签: php node.js curl

我已经从Godaddy购买了Linux服务器。我测试了连接并从远程服务器获取响应,但显示CURL失败。另外,它也不能在Node应用程序上使用。

这是PHP代码:

<?php 
$url = 'http://dev.api/pay';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, "<xml>here</xml>" );

curl_setopt($ch, CURLOPT_PORT, '9085');

$result = curl_exec($ch);
$output = curl_getinfo($ch);

echo "<pre>";
var_dump($output);
echo "</pre>";

curl_close($ch);

var_dump($result);

。实际上,此代码在localhost上有效,但是从服务器访问时无效。如果我租用的服务器防火墙阻止了传出连接,该如何禁用它或允许该端口仅用作我的端口?

1 个答案:

答案 0 :(得分:0)

您具有root访问权吗? 如果是这样,请使用iptables删除传出连接块。

如果您没有root用户,则您的主机将不允许出站连接,您将无能为力。

相关问题