簡體   English   中英

golang 本地反向代理被拒絕

[英]golang local reverse proxy is rejected

func main() {
    http.HandleFunc("/a", func(writer http.ResponseWriter, request *http.Request) {
        remote, _ := url.Parse("http://localhost:9000")
        proxy := httputil.NewSingleHostReverseProxy(remote)
        proxy.ServeHTTP(writer, request)
    })
 
    err := http.ListenAndServe(":8080", nil)
    if err != nil {
        fmt.Println(err)
    }
}

在反向代理提示的本地環境中

http: proxy error: dial tcp 127.0.0.1:9000: connect: connection refused.

防火牆已關閉。 你能告訴我如何解決嗎?

檢查 URL http://localhost:9000 是否在您的本地工作。 如果這不起作用,它可能會關閉。 如果 http 服務器在 9000 端口上運行,它將工作。

如果仍然無法正常工作,請分享有關 http://localhost:9000 URL 的代碼詳細信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM