计算引擎:“无法访问此网站”

时间:2017-02-07 19:10:24

标签: node.js google-cloud-platform google-compute-engine

状况:

我正在关注this教程。

当我到达创建实例的部分并执行必要的命令时,我会进行以下操作:

To see the application running, go to http://[YOUR_INSTANCE_IP]:8080,

where [YOUR_INSTANCE_IP] is the external IP address of your instance.

问题:

页面无法加载。我收到以下错误消息:

This site can’t be reached

问题:

可能出了什么问题?

以前的所有步骤都很完美,我可以在本地访问我的网站。

我等待计算引擎实例准备就绪,方法是检查:

gcloud compute instances get-serial-port-output my-app-instance --zone us-central1-f 

虽然我重复了两次所有步骤,但我仍然遇到了错误信息。

必须遗漏一些东西。

修改

我的防火墙规则:

enter image description here

4 个答案:

答案 0 :(得分:0)

如果您的代码和防火墙规则是正确的,那么您尝试连接到错误的IP的可能性很高。你应该使用外部IP,而不是使用ifconfig使用的内部IP,你可以在whatsmyip.com获得外部IP

答案 1 :(得分:0)

我想您没有将防火墙标签应用于实例?

首先,您可以检查您的计算实例标记。

gcloud compute instances describe my-app-instance

在您的示例中,您应该在标签项中看到http-server,如下所示

tags:
  fingerprint: xxxxxxx
  items:
  - http-server
  - https-server

如果不存在,则应将标签添加到现有的VM实例,请使用以下gcloud命令:

gcloud compute instances add-tags [YOUR_INSTANCE_NAME] --tags http-server,https-server

要在创建实例时添加标签,请在您的语句中包含该标志:

gcloud compute instances create [YOUR_INSTANCE_NAME] --tags http-server,https-server

答案 2 :(得分:0)

我建议调查此步骤:

gcloud compute instances create my-app-instance \
--image-family=debian-9 \
--image-project=debian-cloud \
--machine-type=g1-small \
--scopes userinfo-email,cloud-platform \
--metadata app-location=$BOOKSHELF_DEPLOY_LOCATION \
--metadata-from-file startup-script=gce/startup-script.sh \
--zone us-central1-f \
--tags http-server

请确保实例是使用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"

答案 3 :(得分:0)

首先,检查防火墙设置是否像其他人提到的那样正确。

第二,我遇到了同样的问题,并通过在网络服务层部分选择“标准”选项而不是“高级”选项来解决它。

第三,使用以下命令检查同一端口上是否有其他应用程序正在运行:

<块引用>

netstat -tulpn

应该返回如下内容:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::80                   :::*                    LISTEN      -

就我而言,它不起作用,因为我在同一个端口上运行了两个应用程序。

相关问题