我使用 AWS Ubuntu 实例并尝试打开端口 8080。这是我的“安全组”设置:
我已将端口 8080 添加到 iptables:
sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:http-alt
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
防火墙已禁用:
sudo ufw status verbose
Status: inactive
nmap:
nmap localhost
Starting Nmap 7.60 ( https://nmap.org ) at 2020-05-04 20:27 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00012s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
8080/tcp open http-proxy
网络状态:
netstat -anltp | grep "LISTEN"
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2446/node
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
但是当我使用服务器IP时端口似乎仍然被关闭:
nmap ec2-18-184-30-11.eu-central-1.compute.amazonaws.com
Starting Nmap 7.60 ( https://nmap.org ) at 2020-05-04 20:29 UTC
Nmap scan report for ec2-18-184-30-11.eu-central-1.compute.amazonaws.com (172.31.39.14)
Host is up (0.00013s latency).
rDNS record for 172.31.39.14: ip-172-31-39-14.eu-central-1.compute.internal
Not shown: 999 closed ports
PORT STATE SERVICE
22/tcp open ssh
我应该怎么做才能打开8080端口?
答案1
根据 netstat 输出:
netstat -anltp | grep "LISTEN"
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2446/node
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
该服务将仅响应来自本地主机 (127.0.0.1) 的请求。将其更改为主机上可从调用者网络访问的地址(或 0.0.0.0 用于公共访问)将使该服务可访问。此更改通常在服务配置文档或界面中进行。