简体   繁体   English

如何在本地机器上为节点服务器打开 80 端口?

[英]How to open port 80 for node server on local machine?

How can I use the port 80 on my local Linux machine as the port of my node server?如何使用本地 Linux 机器上的 80 端口作为节点服务器的端口?

The netstat command netstat -ptuln says the following about this port, while the node server is running:当节点服务器正在运行时,netstat 命令netstat -ptuln对这个端口表示以下内容:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:80            0.0.0.0:*               LISTEN      -                  

I found on this site some recommendations for the command sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT .我在这个网站上找到了一些关于命令sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT的建议。 I executed this command but when I make a request with curl ( curl 1.97.xxx.xxx.xx ) it keeps responding with curl: (7) Failed to connect to xxxxxx port 80: Connection refused .我执行了此命令,但是当我使用curlcurl 1.97.xxx.xxx.xx )发出请求时,它一直响应curl: (7) Failed to connect to xxxxxx port 80: Connection refused

But using curl the following ways works: curl 0.0.0.0:80 or curl localhost:80 .但是使用 curl 可以使用以下方法: curl 0.0.0.0:80curl localhost:80

My conclusion is, that I somehow have not opened the port correctly, but all I could find on the internet repetitively is the command I mentioned earlier.我的结论是,我不知何故没有正确打开端口,但我在互联网上反复找到的只是我前面提到的命令。

I am aware of the fact that I could fix this easily by using an apache server, but I would like to make it without it.我知道我可以通过使用 apache 服务器轻松解决这个问题,但我想没有它。

Thank you!谢谢!

Paste the output from粘贴 output 从

netstat -ptuln netstat -ptuln

command.I think the problem is that your web server runs on local address and can not be reachable for other machines in network.命令。我认为问题在于您的 web 服务器在本地地址上运行,网络中的其他机器无法访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM