【问题标题】:Outgoing connection with specific port are being blocked?与特定端口的传出连接被阻止?
【发布时间】: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 专用服务器价格过高,但这不关我的事)

标签: php node.js curl


【解决方案1】:

你有root权限吗? 如果是这样,请使用 iptables 删除传出连接块。

如果您没有 root 访问权限,您的主机只是不允许出站连接,您无能为力。

【讨论】:

  • 是的,你是对的。因为它是共享主机,所以没有办法这样做,因为它需要 root 访问权限。谢谢!
猜你喜欢
  • 2018-04-29
  • 1970-01-01
  • 1970-01-01
  • 2022-01-02
  • 1970-01-01
  • 1970-01-01
  • 2015-08-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多