Digital Ocean 为 spring 引导应用程序打开端口 8080
Digital Ocean open port 8080 for spring boot application
我想 运行 在我的 Ubuntu 16.04.6 x64
droplet 上启动一个简单的 Spring 应用程序。为了允许传入连接,我必须打开 8080 端口,因为这是 spring 引导 jar 中的嵌入式 tomcat 服务器将侦听连接的地方。
我使用了 ufw allow 8080
命令,现在我在 droplet 上看到了这个。
#ufw status
Status: active
To Action From
-- ------ ----
8080 ALLOW Anywhere
22 ALLOW Anywhere
80 ALLOW Anywhere
8080 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
我确定我有我的申请 运行ning:
java -jar myservice.jar &
Netstat 报告正在侦听 8080:
# netstat -aon
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State Timer
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN off (0.00/0/0)
tcp 0 XXX XX.XXX.XX.XXX:22 XX.XX.XXX.XX:64021 ESTABLISHED on (0.11/0/0)
tcp6 0 0 :::8080 :::* LISTEN off (0.00/0/0)
tcp6 0 0 :::22 :::* LISTEN off (0.00/0/0)
然而,当我在服务器外进行 telnet 时,我得到:
telnet XX.XXX.XX.XXX 8080
Connecting To XX.XXX.XX.XXX...Could not open connection to the host, on port 8080: Connect failed
当我在服务器上使用 telnet 时,我得到:
# telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
在 Digital Ocean 的防火墙控制面板中,我有以下设置:
HTTP
对服务器的请求只是挂起,永远不会 return。从缺少日志判断,他们甚至没有到达 tomcat 服务器。
我错过了什么?任何建议将不胜感激!
更新 1:
对我的健康检查端点的本地(服务器内部)curl 请求也挂起。但是我留下了一个更长的时间,我得到了这个应用程序日志:
2019-05-13 18:39:48.723 WARN 5873 --- [nio-8080-exec-2] o.a.c.util.SessionIdGeneratorBase : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [214,287] milliseconds.
这解释了请求挂起的原因,因此应用 解决了这个问题。现在我可以访问服务器上的端点并且它正在响应。
但是在框外,请求仍然没有到达服务器。外面telnet还是说Could not open connection to the host, on port 8080
.
我不是 100% 确定原因,但来自 Digital Ocean Firewall 控制面板的防火墙规则干扰了我的 Droplet 配置。
我已经从控制面板中删除了防火墙规则,现在 netstat 报告我的 8080 端口已打开,我终于可以从外部世界与服务器通信了。
#nmap -sS -O XX.XXX.XX.XXX
Starting Nmap 7.01 ( https://nmap.org ) at 2019-05-13 21:13 UTC
Nmap scan report for myservice (XX.XXX.XX.XXX)
Host is up (0.000024s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
8080/tcp open http-proxy
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.8 - 3.19
Network Distance: 0 hops
还要从问题中检查 UPDATE 1,因为它也造成了奇怪的混乱。
我想 运行 在我的 Ubuntu 16.04.6 x64
droplet 上启动一个简单的 Spring 应用程序。为了允许传入连接,我必须打开 8080 端口,因为这是 spring 引导 jar 中的嵌入式 tomcat 服务器将侦听连接的地方。
我使用了 ufw allow 8080
命令,现在我在 droplet 上看到了这个。
#ufw status
Status: active
To Action From
-- ------ ----
8080 ALLOW Anywhere
22 ALLOW Anywhere
80 ALLOW Anywhere
8080 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
我确定我有我的申请 运行ning:
java -jar myservice.jar &
Netstat 报告正在侦听 8080:
# netstat -aon
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State Timer
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN off (0.00/0/0)
tcp 0 XXX XX.XXX.XX.XXX:22 XX.XX.XXX.XX:64021 ESTABLISHED on (0.11/0/0)
tcp6 0 0 :::8080 :::* LISTEN off (0.00/0/0)
tcp6 0 0 :::22 :::* LISTEN off (0.00/0/0)
然而,当我在服务器外进行 telnet 时,我得到:
telnet XX.XXX.XX.XXX 8080
Connecting To XX.XXX.XX.XXX...Could not open connection to the host, on port 8080: Connect failed
当我在服务器上使用 telnet 时,我得到:
# telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
在 Digital Ocean 的防火墙控制面板中,我有以下设置:
HTTP
对服务器的请求只是挂起,永远不会 return。从缺少日志判断,他们甚至没有到达 tomcat 服务器。
我错过了什么?任何建议将不胜感激!
更新 1:
对我的健康检查端点的本地(服务器内部)curl 请求也挂起。但是我留下了一个更长的时间,我得到了这个应用程序日志:
2019-05-13 18:39:48.723 WARN 5873 --- [nio-8080-exec-2] o.a.c.util.SessionIdGeneratorBase : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [214,287] milliseconds.
这解释了请求挂起的原因,因此应用
但是在框外,请求仍然没有到达服务器。外面telnet还是说Could not open connection to the host, on port 8080
.
我不是 100% 确定原因,但来自 Digital Ocean Firewall 控制面板的防火墙规则干扰了我的 Droplet 配置。
我已经从控制面板中删除了防火墙规则,现在 netstat 报告我的 8080 端口已打开,我终于可以从外部世界与服务器通信了。
#nmap -sS -O XX.XXX.XX.XXX
Starting Nmap 7.01 ( https://nmap.org ) at 2019-05-13 21:13 UTC
Nmap scan report for myservice (XX.XXX.XX.XXX)
Host is up (0.000024s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
8080/tcp open http-proxy
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.8 - 3.19
Network Distance: 0 hops
还要从问题中检查 UPDATE 1,因为它也造成了奇怪的混乱。