无法在 GCP 中访问我的 Ubuntu VM 实例上的 Nexus 控制台

问题描述

我已经在我的 Ubuntu 虚拟机实例上安装了 Nexus(即服务),在创建虚拟机实例时,我还选中了“允许 HTTP 流量”和“允许 HTTPS 流量”选项。

当我执行 $ tail -f /opt/sonatype-work/nexus3/log/nexus.log 时,我看到 Nexus 正在运行:

2021-07-30 06:20:10,046+0000 INFO  [jetty-main-1]  *SYstem org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@73ded096{Sonatype Nexus,/,file:///opt/nexus/public/,AVAILABLE}
2021-07-30 06:20:10,099+0000 INFO  [jetty-main-1]  *SYstem org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@5bb22683{HTTP/1.1,(http/1.1)}{0.0.0.0:8081}
2021-07-30 06:20:10,100+0000 INFO  [jetty-main-1]  *SYstem org.eclipse.jetty.server.Server - Started @48575ms
2021-07-30 06:20:10,101+0000 INFO  [jetty-main-1]  *SYstem org.sonatype.nexus.bootstrap.jetty.JettyServer - 
-------------------------------------------------

Started Sonatype Nexus OSS 3.32.0-03

-------------------------------------------------

当我执行:$ sudo netstat -pnltu | grep -i "8081" 时,我看到:

tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      11722/java 

还有一个 $ sudo systemctl status nexus :

● nexus.service - nexus service
     Loaded: loaded (/etc/systemd/system/nexus.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-07-30 06:19:21 UTC; 27min ago
   Main PID: 11722 (java)
      Tasks: 71 (limit: 4710)
     Memory: 1011.8M
     CGroup: /system.slice/nexus.service
             └─11722 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -server -Dinstall4j.jvmDir=/usr/lib/jvm/java-8-openjdk-amd64/jre -Dexe4j.moduleName=/opt/nexus/>

Jul 30 06:19:21 ubuntu-nexus systemd[1]: Starting nexus service...
Jul 30 06:19:21 ubuntu-nexus nexus[11541]: Starting nexus
Jul 30 06:19:21 ubuntu-nexus systemd[1]: Started nexus service.

但是,当我尝试通过 vm 实例的外部 ip 和 nexus 端口访问 Nexus 控制台时-> http://34.xxx.xx.xxx:8081/ 我无法访问它(无法访问此站点)。

GCP 中是否有任何防火墙设置需要完成?

解决方法

“允许 HTTP 流量”和“允许 HTTPS 流量”只打开 80 和 443 端口,而 Nexus 正在监听 8081 端口。更改监听端口或打开 8081 端口

,

根据上面@Martheen 的回答,我创建了

  1. 防火墙规则 > opened port 8081
  2. 将规则应用到我的 VM 实例(通过在网络部分提及规则标签)

像魅力一样工作!