【发布时间】:2019-09-04 18:32:33
【问题描述】:
我从 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 上运行,但是从服务器访问时它不起作用。如果传出连接被我租用的服务器防火墙阻止,我该如何禁用它或允许我只打算使用的端口?
【问题讨论】:
-
您正在尝试通过端口 8075 连接到它,请尝试使用端口 80。
-
不,你没有明白这一点。远程服务器是一个在端口 8075 上提供服务的 API
-
我认为您应该改为在unix.stackexchange.com 询问 - 但是您从
sudo iptables -S得到什么? (顺便说一句,iirc,与他们的网络托管服务不同,godaddy 专用服务器价格过高,但这不关我的事)