Golang http.Client{} blocked by cloudflare

I have a Go service behind cloudflare (backup.foo.com/push) that I have tested with CURL/chrome and I have verified that it works and is indeed accessible. However, when using Golang's http.Client{} to make a POST request to the service, it returns the following:
Server responded with status code 500 Internal Server Error
2024/02/13 08:32:19 Body bytes:
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
Server responded with status code 500 Internal Server Error
2024/02/13 08:32:19 Body bytes:
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
client.go
...
req, err := http.NewRequest(http.MethodPost, serverURL, tarballReader)
if err != nil {
log.Fatalf("Error creating tarball request: %v\n", err)
}

req.Header.Set("timestamp", startTime.Format(time.RFC3339))
req.Header.Set("Authorization", "MYAUTHTOKEN")
req.Header.Set("Content-Type", "application/gzip")
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_7; en-US) AppleWebKit/537.44 (KHTML, like Gecko) Chrome/48.0.2965.325 Safari/601")
log.Println("Starting serverside pg_restore request...")

httpReqStartTime := time.Now()
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalf("Error pushing tarball to remote server: %v\n", err)
}
defer resp.Body.Close()

log.Printf("Server responded with status code %v\n", resp.Status)
...
...
req, err := http.NewRequest(http.MethodPost, serverURL, tarballReader)
if err != nil {
log.Fatalf("Error creating tarball request: %v\n", err)
}

req.Header.Set("timestamp", startTime.Format(time.RFC3339))
req.Header.Set("Authorization", "MYAUTHTOKEN")
req.Header.Set("Content-Type", "application/gzip")
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_7; en-US) AppleWebKit/537.44 (KHTML, like Gecko) Chrome/48.0.2965.325 Safari/601")
log.Println("Starting serverside pg_restore request...")

httpReqStartTime := time.Now()
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalf("Error pushing tarball to remote server: %v\n", err)
}
defer resp.Body.Close()

log.Printf("Server responded with status code %v\n", resp.Status)
...
1 Reply
goybley
goybley4mo ago
I have verified that it is indeed cloudflare that is returning HTTP 500, not my webserver. My server is set to log every request made to /backup, and it's not logging anything. The request isn't making it through I don't have any bot rules, ddos rules, etc... Just the default cloudflare configuration for a proxied domain.