nginx proxy_pass /使用go app提供404

问题描述 投票:1回答:1

我有一个简单的go应用,可通过nginx proxy_pass提供html。我的问题是我在/上得到了404,其他指令工作正常。有什么想法吗?

nginx配置文件

server {
        listen 80 default_server;
        listen [::]:80 default_server;

 location  / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://localhost:8001;
      }

 location /codcall {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://localhost:8001;
   }
 location /codcall-dev {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://localhost:8001;
   }
}

我的Go应用程式路线

func main() {
        http.HandleFunc("/", indexHandler)
        http.HandleFunc("/codcall", indexHandler)
        http.HandleFunc("/codcall-dev", indexHandler)
        http.ListenAndServe(":8001", nil)

}
go nginx nginx-reverse-proxy
1个回答
0
投票

必须在已加载的配置和我认为已加载的配置之间有些混淆。我重新启动了我的vps,并仔细检查了所有配置是否正确以及它现在是否正常运行。

© www.soinside.com 2019 - 2024. All rights reserved.