我在CentOS 8中使用node.js创建了Web服务器。但它不工作。
这是我的node.js Web服务器。
const http = require('http');
const hostname = '0.0.0.0';
const port = '8080';
httpd = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
});
httpd.listen(port, hostname, function(){
console.log('Server Start');
});
我发送ping到centos的端口22和8080。我无法收到响应只有端口8080。
C:\Users\user>tcping -p 22 <centOS IP>
Probing <centOS IP>:22/tcp - Port is open - time=14.019ms
Probing <centOS IP>:22/tcp - Port is open - time=13.159ms
Probing <centOS IP>:22/tcp - Port is open - time=8.601ms
Probing <centOS IP>:22/tcp - Port is open - time=9.896ms
C:\Users\user>tcping -p 8080 <centOS IP>
Probing <centOS IP>:8080/tcp - No response - time=2010.980ms
Probing <centOS IP>:8080/tcp - No response - time=2008.277ms
Probing <centOS IP>:8080/tcp - No response - time=2008.509ms
Probing <centOS IP>:8080/tcp - No response - time=2000.949ms`
我检查了下面的信息。(我检查了监听端口8080)(我关闭了防火墙,iptables...)
<Linux>
[opc@instance-20220607-1056 webTest]$ netstat -tnlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9003 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
.
.
[opc@instance-20220607-1056 webTest]$ sudo service iptables status
Redirecting to /bin/systemctl status iptables.service
Unit iptables.service could not be found.
[opc@instance-20220607-1056 webTest]$ sudo systemctl status nftables
nftables.service - Netfilter Tables
Loaded: loaded (/usr/lib/systemd/system/nftables.service; disabled; vendor p>
Active: inactive (dead)
Docs: man:nft(8)
lines 1-4/4 (END)
[opc@instance-20220607-1056 webTest]$ sudo systemctl status firewalld
firewalld.service
Loaded: masked (Reason: Unit firewalld.service is masked.)
Active: inactive (dead)
Jan 05 17:49:52 instance-20220607-1056 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 05 17:49:54 instance-20220607-1056 systemd[1]: Started firewalld - dynamic firewall daemon.
Jan 05 17:49:54 instance-20220607-1056 firewalld[1480]: WARNING: AllowZoneDrifting is enabled. This is consi>
Jan 05 20:38:06 instance-20220607-1056 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jan 05 20:38:10 instance-20220607-1056 systemd[1]: firewalld.service: Succeeded.
Jan 05 20:38:10 instance-20220607-1056 systemd[1]: Stopped firewalld - dynamic firewall daemon.
[opc@instance-20220607-1056 webTest]$ sudo lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: OracleServer
Description: Oracle Linux Server release 8.7
Release: 8.7
Codename: n/a
我还应该检查什么?谢谢你的回答。
1条答案
按热度按时间lsmd5eda1#
此问题发生在Oracle云设置中,我通过参考下面的链接解决了此问题。link