在Web浏览器中查看Cloud Compute Engine应用程序 [英] Viewing Cloud Compute Engine Application in Web Browser
问题描述
我有一个Dash应用程序,可以在本地运行并在浏览器中查看.我已将其移至Google Cloud Compute Engine并运行了该应用程序,但在运行它的127.0.0.1地址的浏览器中却看不到它.我尝试使用以下方式允许http和https通信到虚拟机 gcloudcompute防火墙规则在控制台中创建FIREWALL_RULE --allow tcp:80,tcp:443
,没有任何运气.如何在浏览器中查看它?
I have a Dash application that I can run locally and view in my browser. I have moved it to Google Cloud Compute Engine and the app runs, but I can't see it in my browser at the 127.0.0.1 address where it's running.
I have tried to allow http and https traffic to the virtual machine using
gcloud compute firewall-rules create FIREWALL_RULE --allow tcp:80,tcp:443
in the console without any luck. How can I view it in my browser?
推荐答案
您可以访问 http://127.0.0.1
和/或 https://127.0.0.1
在本地运行时,因为您在同一台计算机上运行网络浏览器.您可以在此处:
You were able to reach http://127.0.0.1
and/or https://127.0.0.1
when you run it locally because you run your web browser on the same computer. More information you can find here:
本地环回机制可用于在网络上运行网络服务.主机而无需物理网络接口,或无需可从计算机可能连接的网络访问的服务至.例如,可以从Web浏览器通过URL http://localhost 来显示其主页.
The local loopback mechanism may be used to run a network service on a host without requiring a physical network interface, or without making the service accessible from the networks the computer may be connected to. For example, a locally installed website may be accessed from a Web browser by the URL http://localhost to display its home page.
名称localhost通常解析为IPv4回送地址127.0.0.1,并指向IPv6环回地址:: 1.
The name localhost normally resolves to the IPv4 loopback address 127.0.0.1, and to the IPv6 loopback address ::1.
因此,您只能从您的VM实例访问位于VM实例上的IP 127.0.0.1
.
As result, you can access IP 127.0.0.1
located on your VM instance only from your VM instance.
要在IP 127.0.0.1
上检查您的应用程序,可以在虚拟机实例的命令行中使用命令 curl
:
instance:~$ curl -I http://127.0.0.1
instance:~$ curl -I https://127.0.0.1
要允许通过端口80/443访问您的应用程序,您应该转到 Compute Engine
-> VM instance
->单击<代码> NAME_OF_YOUR_VM_INSTANCE ->单击 EDIT
->转到 防火墙
并选择允许HTTP流量
和允许HTTP流量
->单击保存
.查看文档防火墙规则概述和
To allow access to your application via ports 80/443 you should go to Compute Engine
-> VM instances
-> click on NAME_OF_YOUR_VM_INSTANCE
-> click on EDIT
-> go to Firewalls
and select Allow HTTP traffic
and Allow HTTP traffic
-> click Save
. Have a look at the documentation Firewall rules overview and Configuring network tags to find more details.
要通过Web浏览器访问您的应用程序,您应该使用在 Compute Engine
-> VM实例
->中可以找到的外部IP地址.寻找 NAME_OF_YOUR_VM_INSTANCE
和 外部IP
:
To access your application from web browser you should use external IP address that you can find at Compute Engine
-> VM instances
-> look for NAME_OF_YOUR_VM_INSTANCE
and External IP
:
http://EXTENAL_IP_OF_YOUR_VM_INSTANCE
https://EXTENAL_IP_OF_YOUR_VM_INSTANCE
这篇关于在Web浏览器中查看Cloud Compute Engine应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!