连接到远程 8080 端口时,我的服务器的 8080 端口是否必须打开?
我正在尝试使用 fsockopen() 从我的 apache 服务器连接到远程 API 服务器。我需要连接的远程服务器脚本在端口8080上运行。
以下内容不断返回101连接超时
错误:
$fp = fsockopen('remote.example.com', '8080', $errno, $errstr, 10);
我需要在上打开端口8080吗我的服务器以便连接到远程服务器上的该端口?
如果是这样,有什么方法可以使用例如 .htaccess
来做到这一点,或者我必须为此修改 httpd.conf 吗?
谢谢!
添加
感谢大家的回复。你们都对,但我只能接受1个答案,所以我接受了第一个。
如果有人感兴趣:这是在 Wiredtree 服务器上,在向支持人员发送电子邮件后,他们说出于安全原因(也包括 cURL),他们默认禁用它,但他们可以根据请求启用它。我确信一旦他们这样做了,这个问题就会得到解决。
我想我会发布这个以防其他人将来遇到同样的问题。
I'm trying to use fsockopen() to connect from my apache server to a remote API server. The remote server script I need to connect to runs on port 8080.
The following keeps returning a 101 connection timed out
error:
$fp = fsockopen('remote.example.com', '8080', $errno, $errstr, 10);
Do I need to open port 8080 on my server in order to connect to that port on the remote server?
And if so, is there any way to do that using e.g. .htaccess
, or would I have to modify httpd.conf for that?
Thanks!
ADDED
Thanks everybody for the replies. You were all correct, but I can only accept 1 answer, so I accepted the first one.
If anyone is interested: this is on a Wiredtree server and after emailing support, they said that they have that disabled by default for security reasons (also cURL), but they can enable it upon request. I'm sure that once they do, this problem will be solved.
Thought I'd post this in case anyone else is experiencing the same problem in the future.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,你不需要。当您连接到另一台服务器时,您的服务器将成为客户端,并且客户端的端口号是从动态端口范围中选择的。
No, You need not. When you connect to another server, your server is being the client, and the client's port number is chosen from the dynamic port range.
一般来说,除非明确阻止,否则所有端口都向向外开放。我认为这里还有其他东西在起作用。远程 API 服务器是否正在运行?它确实在端口 8080 上运行吗?您可以检查一下吗?您是否尝试过使用 telnet 连接到端口 8080?
Generally speaking, all ports are open going outwards unless explicitly blocked. I think there's something else at play here. Is the remote API server running? Is it indeed running on port 8080 and can you check? Have you tried to connect using telnet to port 8080?
不,您不必打开服务器的 8080 端口。您是否在公司或政府环境中,您可能坐在代理服务器后面?如果是这样,您可能无法在不通过代理的情况下到达该目的地。
No, you do not have to open your server's 8080 port. Are you in a corporate or government setting where you might be sitting behind a proxy server? If so you might not be able to reach that destination without going through the proxy.