dtds8802 2016-07-15 18:57
浏览 18
已采纳

GAE go仅在localhost上提供路径,在域上不提供服务

I am messing around with a small go app for google app engine locally using the appengine sdk.

I have a problem where a path different than root can only be served if I try to hit it using localhost, but not a domain name.

My setup is as follows.

  • home.mydomain.com points to my home ip adress
  • My home router forwards incoming tcp and udp on port 80 to my laptop on port 8080
  • My laptop is running Windows 10
  • My go version is go1.6 windows/amd64

My app.yaml:

application: tasks
version: 1
runtime: go
api_version: go1

handlers:
- url:  /.*
  script: _go_app

Minimum example code:

func init() {
    fileHandler := http.FileServer(http.Dir("../frontend"))

    http.HandleFunc("/loggedout", testHandler)
    http.Handle("/", fileHandler)

    log.Print(http.ListenAndServe(":8080", nil))
}

func testHandler(res http.ResponseWriter, req *http.Request){    
    panic("JUST NEED THIS TO WORK")
}

My symptoms is that if I access localhost:8080/ I get my website, and if I access localhost:8080/loggedout I get the expected panic.
If I access home.mydomain.com/ I get my website, however if I access home.mydomain.com/loggedout the connection just hangs, in chromes network tab it is listed as pending indefinitely.

  • 写回答

1条回答 默认 最新

  • donh61500 2016-07-19 06:07
    关注

    As Greg pointed out, when I was using goapp I did not need to also call ListenAndServe. To get goapp to listen for requests outside of localhost I also had to add --host "my laptops ip" to the command.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记