如何在Cloud9 IDE中打开localhost:8080?

huangapple go评论84阅读模式
英文:

How to open localhost:8080 in Cloud9 IDE?

问题

我正在使用Cloud9 IDE开发一个App Engine项目(使用golang)。在桌面上进行测试时,我会在我的桌面浏览器中输入localhost:8080。

在Cloud9中,我尝试使用https://workspace-username.c9.io,并将$PORT设置为8080,但是对于App Engine项目来说,这种方法似乎不起作用。但是对于普通的go web项目来说,它是可以工作的。

我该如何在Cloud9 IDE中测试App Engine应用程序?或者

我该如何在Cloud9 IDE中打开http://localhost:8080?

英文:

I am developing an app engine project (golang) in Cloud9 IDE. For testing in desktop i would go to localhost:8080 in my desktop browser.

In Cloud9, I tried https://workspace-username.c9.io with $PORT set as 8080, but somehow its not working for appengine project. But it is working for normal go web project though.

How do i test app engine application in Cloud9 IDE? or

How do i open http://localhost:8080 in Cloud9 IDE?

答案1

得分: 2

托管的Cloud9工作区上可用的端口

如果您正在开发服务器应用程序,请注意您需要监听0.0.0.0($IP)和8080($PORT)。监听此端口将使您的应用程序可以在https://-.c9users.io上查看。

您还可以绑定到端口8081和8082,分别可以通过https://-.c9users.io:8081和https://-.c9users.io:8082访问。

请注意,托管的Cloud9工作区上只有8080、8081和8082这三个可用端口。

https://stackoverflow.com/questions/15990818/how-to-connect-to-the-process-running-on-localhost-that-is-inside-of-cloud9-se/41006916#41006916

英文:

Available ports on a hosted Cloud9 workspace

> If you're developing a server application, please note that you need
> to listen to 0.0.0.0 ($IP) and 8080 ($PORT). Listening to this port
> will enable your app to be viewable at https://-.c9users.io
>
> You can also bind to ports 8081, and 8082, which can be accessed by
> https://-.c9users.io:8081 and https://-.c9users.io:8082 respectively.
>
> Please note that 8080, 8081, and 8082 are the only available ports on
> a hosted Cloud9 workspace.

https://stackoverflow.com/questions/15990818/how-to-connect-to-the-process-running-on-localhost-that-is-inside-of-cloud9-se/41006916#41006916

答案2

得分: 1

我看到一些用户正在寻找这个问题的答案,所以这里是如何做到的。

不要使用"goapp serve",而是使用"goapp serve -host 0.0.0.0"

感谢Cloud9支持团队。

英文:

I see some users are looking for the answer for this, So here is how to do it.

instead of "goapp serve" use "goapp serve -host 0.0.0.0"

credits to Cloud9 support team.

答案3

得分: 1

对于运行Python的Google App Engine,命令应该是:

dev_appserver.py app.yaml --host $IP --port $PORT --admin_host $IP --admin_port 8081

您还可以指定管理员主机/端口。由于Cloud 9允许访问8081和8082端口,您可以将其中任何一个作为管理员端口使用。对我来说,在Cloud9预览中管理员控制台没有打开,但在我的浏览器中的新标签页中打开了。

$IP和$PORT都是Cloud 9的环境变量,分别具有值0.0.0.0和8080。

编辑:
在最新的gcloud更新(2018年3月)中,您不需要更改IP或PORT,但您需要找出如何解决主机白名单问题。
我不太理想的解决方法是添加一个标志来不检查主机 --enable_host_checking=false

dev_appserver.py app.yaml --enable_host_checking=false

关于此问题还有一个未回答的Cloud 9帖子(c9论坛链接)。我猜您可以将$C9_HOSTNAME添加为主机,但对我来说这并不完全有效。

交互式控制台

如果您想使用交互式控制台,您需要分配管理员端口并使用--enable_console标志。

dev_appserver.py app.yaml --enable_host_checking=false --admin_port 8081 --enable_console=true

英文:

For Google App Engine running Python, the command would be

dev_appserver.py app.yaml --host $IP --port $PORT --admin_host $IP --admin_port 8081

You can also specify the admin host/port. Since Cloud 9 allows access to 8081 and 8082, you can use either of those as your admin ports. For me, the admin console did not open with the Cloud9 preview, but did open in a new tab within my browser.

$IP and $PORT are both environment variables for Cloud 9, with the values of 0.0.0.0 and 8080 respectively.

Edit:
With the most recent gcloud update (March 2018), you don't have to change the IP or PORT, but you do need to figure out how to work around the host whitelisting issue.
My non-ideal workaround is to add a flag to not check for hosts --enable_host_checking=false.

dev_appserver.py app.yaml --enable_host_checking=false

There's an unanswered Cloud 9 post around this issue (link to c9 forum). My guess is that you can add $C9_HOSTNAME as the host, but that doesn't quite work for me.

Interactive Console

If you want to use the interactive console you need to assign the admin port and also use the `--enable_console' flag.

dev_appserver.py app.yaml --enable_host_checking=false --admin_port 8081 --enable_console=true

huangapple
  • 本文由 发表于 2015年1月20日 03:22:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/28032055.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定