httputil proxy integrity errors on serving hugo/nginx files

30 views
Skip to first unread message

Sankar

unread,
Dec 4, 2019, 7:27:48 AM12/4/19
to golang-nuts
I have a Go proxy server which will proxy the incoming requests to a different nginx service, where a bunch of static files generated from hugo are deployed. The Go proxy server code is:

```
func (w http.ResponseWriter, r *http.Request) {
    proxy := httputil.NewSingleHostReverseProxy(target)
    proxy.Transport = debug.Transport{} // Set some Debug TCP options here
    proxy.ServeHTTP(w, r)
}
```
The debug.Transport is created like below:

```
type Transport struct {
    Transport http.RoundTripper
}

func (d Transport) RoundTrip(r *http.Request) (*http.Response, error) {
    fmt.Println(r.Header)
    d.Transport = &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    }
    return d.Transport.RoundTrip(r)
}
```

In the debug Transport, I am already ignoring the certificate checks for TLS configuration.

If I directly access the nginx url where hugo static files are served, then the static files are perfectly loaded. The static files are served fine even if I access from an nginx-ingress in addition to the nginx. However, when the requests are served via the Go proxy, then I get an error in my browser:

```
Failed to find a valid digest in the 'integrity' attribute for resource 'https://<blah>/js/main.min.29b0315468c00226fa6f4556a9cebc0ac4fe1ce1457a01b22c0a06b329877383.js' with computed SHA-256 integrity 'Nk/s9htIgKJ5jeLFxUMWgIQGhxGZBKoEWtWEy2qYtJk='. The resource has been blocked.
```


Any idea how I can skip this integerity check in the Go http proxy ? I cannot find any TLS Config option for it.

Thanks.
Reply all
Reply to author
Forward
0 new messages