看不到实例外部 IP 上运行的应用程序



Google Compute Engine 新手在这里。

我正在按照书架教程进行操作:https://cloud.google.com/nodejs/tutorials/bookshelf-on-compute-engine

但是遇到了一个问题。当我尝试使用外部 IP 在http://[YOUR_INSTANCE_IP]:8080上查看我的应用程序时

什么都没有出现。我尝试一次又一次地运行本教程,但仍然存在相同的问题。

编辑:

我的防火墙规则:https://i.stack.imgur.com/Hcsyb.png

我的虚拟机实例: https://i.stack.imgur.com/sxpgP.png

显示正确网络标记的虚拟机实例: https://i.stack.imgur.com/OlSCK.png

在我的网络浏览器中 http://35.189.73.115:8080/仍然无法显示任何内容。显示"此页面不起作用">

TL;DR- 您很可能缺少防火墙规则,以允许传入流量到实例上的端口 8080。

默认防火墙规则

默认情况下,Google 计算引擎防火墙会阻止到虚拟机的所有入口流量(即传入的网络流量(。如果 VM 是在默认网络上创建的(通常是这种情况(,则允许使用很少的端口,例如 22 (ssh(、3389 (RDP(。

此处介绍了默认防火墙规则。

打开入口端口

此处详细介绍了入口防火墙规则。

建议的方法是创建防火墙规则,该规则允许传入端口8080上的 VM(包含所选的特定标记(的流量。然后,只能将此标记关联到要允许入口8080的虚拟机。

使用gcloud执行此操作的步骤:

# Create a new firewall rule that allows INGRESS tcp:8080 with VMs containing tag 'allow-tcp-8080'
gcloud compute firewall-rules create rule-allow-tcp-8080 --source-ranges 0.0.0.0/0 --target-tags allow-tcp-8080 --allow tcp:8080
# Add the 'allow-tcp-8080' tag to a VM named VM_NAME
gcloud compute instances add-tags VM_NAME --tags allow-tcp-8080
# If you want to list all the GCE firewall rules
gcloud compute firewall-rules list

下面是另一个堆栈溢出答案,它将引导你了解如何使用云控制台 Web UI(除了gcloud之外(允许特定端口上的入口流量进入 VM。

PS:这些也是您链接的教程中步骤的一部分。

# Add the 'http-server' tag while creating the VM
gcloud compute instances create my-app-instance 
--image=debian-8 
--machine-type=g1-small 
--scopes userinfo-email,cloud-platform 
--metadata-from-file startup-script=gce/startup-script.sh 
--zone us-central1-f 
--tags http-server
# Add firewall rules to allow ingress tcp:8080 to VMs with tag 'http-server'
gcloud compute firewall-rules create default-allow-http-8080 
--allow tcp:8080 
--source-ranges 0.0.0.0/0 
--target-tags http-server 
--description "Allow port 8080 access to http-server"

相关内容

最新更新