ReverseProxy per Host

124 views
Skip to first unread message

Besart Dollma

unread,
Apr 5, 2022, 1:00:15 PM4/5/22
to golang-nuts
I am trying to make a reverse proxy that will redirect HTTP packets to different hosts based on a tenant embedded in the URL.

The implementation is attached as a screenshot.

I get this error: 

2022/04/05 12:31:01 http: proxy error: readfrom tcp **** http: invalid Read on closed Body
2022/04/05 12:31:01 http: superfluous response.WriteHeader call from net/http/httputil.(*ReverseProxy).defaultErrorHandler (reverseproxy.go:190)

If i don't reuse the proxy object, but rather spawn a new proxy each request everything works fine.

From my understanding the proxy object should be per host and not per request, as such i can keep reusing it for different requests. What am I missing?

I know that I need to protect these maps with a mutex but that is irrelevant at the moment.

Thanks, 


Screen Shot 2022-04-05 at 12.40.11.png
Reply all
Reply to author
Forward
0 new messages