我想在我的设备上运行一个简单的 Spring Boot 应用程序Ubuntu 16.04.6 x64
水滴。为了允许传入连接,我必须打开 8080 端口,因为这是 spring boot jar 中的嵌入式 tomcat 服务器将侦听连接的地方。
我用的是ufw allow 8080
命令,现在我在我身上看到了这个水滴。
#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)
我确保我的应用程序正在运行:
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
对服务器的请求只是挂起并且永远不会返回。从缺乏日志来看,它们甚至没有到达 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.
这解释了为什么请求被挂起,所以申请这篇文章的答案 https://stackoverflow.com/questions/28201794/slow-startup-on-tomcat-7-0-57-because-of-securerandom解决了这个问题。现在我可以访问服务器上的端点并且它正在响应。
然而在盒子之外,请求仍然没有到达服务器。 Telnet 外面仍然说Could not open connection to the host, on port 8080
.