我从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,但是从服务器访问时它不起作用。如果从我租用的服务器防火墙中阻止传出连接,我该如何禁用它或允许我打算只使用该端口?
你有root访问权限吗?如果是这样,请使用iptables删除传出连接块。
如果您没有root访问权限,则主机不允许出站连接,您无法对其进行任何操作。