App Engine Go SDK web server running in Vagrant guest (with port forwarding) not reachable from host

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

App Engine Go SDK web server running in Vagrant guest (with port forwarding) not reachable from host

问题

我正在一个 Vagrant 的 precise64 虚拟机中运行 GAE 开发服务器,并使用以下网络设置(在我的 Vagrantfile 中):

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.network :forwarded_port, guest: 8080, host: 9090
end

这样设置后,端口转发生效:

[default] Forwarding ports...
[default] -- 8080 => 9090 (adapter 1)

我使用以下命令启动 App Engine 服务器:

goapp serve

或者

dev_appserver.py myappfolder

这会如预期地启动 App Engine 开发服务器:

INFO 2013-11-22 dispatcher.py] Starting module running at: http://localhost:8080

在所有情况下,我能够通过 SSH 连接到 Vagrant 虚拟机,并成功使用 curl 访问 localhost:8080

不幸的是,从 主机 上无法从 localhost:9090 获取到 GAE 开发 Web 服务器的响应。此外,我确保主机上没有任何干扰端口 9090 的东西。而且,我几乎可以确定这与 Vagrant 无关,因为我在 8080 端口上快速启动了一个 node.js Web 服务器,并且能够从主机访问它。我漏掉了什么?!!!

英文:

I'm running GAE dev server within a Vagrant guest precise64 box with the following network setup (in my Vagrantfile):

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.network :forwarded_port, guest: 8080, host: 9090
end

Which does its thing:

[default] Forwarding ports...
[default] -- 8080 => 9090 (adapter 1)

I start my App Engine server with:

goapp serve

or

dev_appserver.py myappfolder

This starts app engine dev server as expected:

INFO 2013-11-22 dispatcher.py] Starting module running at: http://localhost:8080

In all cases, I'm able to ssh in to the Vagrant guest and curl localhost:8080 successfully.

Unfortunately, from the host I'm unable to get a response from localhost:9090 when running GAE dev web server. Additionally, I've made sure that I don't have anything interfering with the port 9090 on the host machine. Also, I'm almost positive this isn't related to Vagrant as I spun up a quick node.js web server on 8080 and was able to reach it from the host. What am I missing?!!!

答案1

得分: 8

当使用Vagrant端口转发时,您必须在0.0.0.0上运行Google App Engine Go dev web server。像这样:

goapp serve -host=0.0.0.0

请参阅这里的答案,了解更多关于确保客户端Web服务器不绑定到127.0.0.1(回环地址)的信息。默认情况下,绑定到127.0.0.1的Web服务器(如App Engine Go dev web server)应该被覆盖为使用0.0.0.0。

英文:

You must run the Google App Engine Go dev web server on 0.0.0.0 when leveraging Vagrant port forwarding. Like so:

goapp serve -host=0.0.0.0

See the answers here for more info on ensuring the guest web server is not bound to 127.0.0.1 which is loopback. Web servers that bind to 127.0.0.1 (like App Engine Go dev web server does) by default should be overridden to use 0.0.0.0.

huangapple
  • 本文由 发表于 2013年11月23日 07:00:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/20156077.html
匿名

发表评论

匿名网友

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

确定