如何通过浏览器访问 Google Cloud Engine 实例的 IP 地址 [英] How to access Google Cloud Engine instance's IP address via browser

查看:23
本文介绍了如何通过浏览器访问 Google Cloud Engine 实例的 IP 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过这个

我创建了一个新的防火墙规则来接受任何传入的请求(实际上我需要这样做吗?default-allow-http 有相同的规则吗?):

但是当我尝试使用 Chrome 访问 IP 时,出现错误.即使我更改浏览器,错误仍然存​​在,例如IE 或 Firefox:

我已经确认可以 ping 地址:

我什至尝试为实例分配一个域名,但它仍然不起作用:

我可以知道我做错了什么吗?

希望得到任何建议!提前致谢!

解决方案

我在安装 JIRA Core 应用后遇到了同样的问题,我通过以下步骤解决了它.老实说,我没有安装MEAN堆栈,但解决此错误的大部分步骤必须相同(端口验证和服务执行除外).

  1. 首先是在官方文档和app安装生成的一些配置文件中检测MEAN stack app使用的端口.根据评论中的信息,该应用使用端口 3000

  2. 您转到 GCP 控制台添加 VPC 网络防火墙规则.

    一个.您选择拥有实例的项目.

    B.选择 VPC 网络 -> 防火墙规则 -> 创建

    c.名称:均值栈

    d.IP间隔:0.0.0.0/0

    e.协议/端口:tcp:3000;udp:3000

  3. 列出虚拟机正在侦听或防火墙从 Cloud Shell 启用的端口:

    <代码>$ netstat -an |grep听"

  4. 您必须为阻止防火墙的 MEAN 堆栈打开端口.如果端口正在侦听,则不需要此步骤:

    $ sudo apt-get install ufw

    $ sudo ufw enable

    $ sudo ufw allow ssh//以免被ssh与实例断开

    $ sudo ufw 允许 3000

    如果应用程序使用更多控制端口,您还必须启用它们

  5. 您应该使用一些命令检查应用程序是否已打开并正在运行(例如:sudo/opt/bitnami/ctlscript.sh start apache)

  6. 您应该测试是否可以通过 URL 在本地访问 MEAN 堆栈应用程序.以下命令不必让我拒绝连接.

    $ sudo wget http://localhost:3000

    不要输入 wget 生成的 URL,因为它必须使用外部 ip 来完成.

  7. 最后,在为实例的项目创建防火墙规则并启用阻止防火墙的端口后,您可以从任何客户端通过浏览器访问.

    http://<外部 ip-vm >:<端口 >

    <块引用>

    http://104.154.39.199:3000

我希望我能在某个时候帮助你.GL

I installed a MEAN stack on Google Cloud Engine (GCE) via this link.

So the engine created my instance successfully and it looks like this:

I created a new firewall rule to accept any incoming requests (actually do I need to do this? default-allow-http has the same rule right?):

But when I try to access the IP using Chrome, I get an error. The error persists even when I change the browser e.g. IE or Firefox:

I have confirmed that I can ping the address:

I even tried to assign a domain name to the instance but it still does not work:

May I know what I am doing wrongly?

Would appreciate any advice! Thanks in advance!

解决方案

I had the same problem after installing the JIRA Core app, and I was able to solve it with the following steps. I honestly did not install MEAN stack but most of the steps to solve this error must be the same (except for port verification and service execution).

  1. The first thing is to detect the port used by MEAN stack app in the official documentation and in some configuration file generated by the installation of the app. According to information in the comments the app uses the port 3000

  2. You go to the GCP console to add a VPC Network firewall rule.

    a. You choose the project where you have the instance.

    b. Select VPC Network -> Firewall Rules -> Create

    c. Name: mean-stack

    d. Intervals of IPs: 0.0.0.0/0

    e. Protocols/ports: tcp:3000; udp:3000

  3. List the ports that the VM is listening to or the firewall enables from the Cloud Shell:

    $ netstat -an | grep "LISTEN "

  4. You have to open the port for MEAN stack that blocks the firewall. If the port is listening, this step is not necessary:

    $ sudo apt-get install ufw

    $ sudo ufw enable

    $ sudo ufw allow ssh //so as not to be disconnected from the instance by ssh

    $ sudo ufw allow 3000

    If the app uses more control ports, you must also enable them

  5. You should check that the app is on and running with some command (For example: sudo /opt/bitnami/ctlscript.sh start apache)

  6. You should test if you can access the MEAN stack app locally through the URL. The following command does NOT have to give me connection refused.

    $ sudo wget http://localhost:3000

    Do not enter the URL generated by wget, as it must be done with an external ip.

  7. Finally, after creating a firewall rule for the project of the instance and enabling the port that blocks the firewall you can access from any client through the browser.

    http://< external-ip-vm >:< port >

    http://104.154.39.199:3000

I hope I can help you at some point. GL

这篇关于如何通过浏览器访问 Google Cloud Engine 实例的 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆