反向代理不起作用

I am using GO's reverse proxy like this, but this does not work well

package main

import (
    "net/http"
    "net/http/httputil"
    "net/url"
)

func main() {
    u, _ := url.Parse("http://www.darul.io")

    http.ListenAndServe(":9000", httputil.NewSingleHostReverseProxy(u))
}

when I visit the http://localhost:9000, I am seeing not expected page

enter image description here

From this article A Proper API Proxy Written in Go:

httputil.NewSingleHostReverseProxy does not set the host of the request to the host of the destination server. If you’re proxying from foo.com to bar.com, requests will arrive at bar.com with the host of foo.com. Many webservers are configured to not serve pages if a request doesn’t appear from the same host.

You need to define a custom middleware to set the required host parameter:

package main

import (
        "net/http"
        "net/http/httputil"
        "net/url"
)

func sameHost(handler http.Handler) http.Handler {
        return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                r.Host = r.URL.Host
                handler.ServeHTTP(w, r)
        })
}

func main()  {
        // initialize our reverse proxy
        u, _ := url.Parse("http://www.darul.io")
        reverseProxy := httputil.NewSingleHostReverseProxy(u)
        // wrap that proxy with our sameHost function
        singleHosted := sameHost(reverseProxy)
        http.ListenAndServe(":5000", singleHosted)
}