I am sending HTTP GET request in my App
When I send the request using http.Get(URL)
just like the following code I get 200 as HTTP status code:
resp, err := http.Get("https://www.google.co.in/")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "HTTP GET returned status %v", resp.Status)
But if I use http.NewRequest()
and http.Client
just like the following code I get 502 Bad Gateway nginx
error
req, err := http.NewRequest("GET", "https://www.google.co.in/", nil)
resp, err := client.Do(req)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "HTTP GET returned status %v", resp.Status)
I checked Stackdriver log for nginx.error
I see the following error
[error] 32#32: *6597 upstream prematurely closed connection while
reading response header from upstream, client: $client_ip, server: ,
request: "GET /check HTTP/1.1", upstream:
"http://172.17.0.1:8080/check", host: "XXX.appspot.com"
I am new to App Engine and also I have limited knowledge of Nginx.