How to create a simple http proxy server in golang?

3,109 views
Skip to first unread message

Anindya Chatterjee

unread,
Jun 17, 2014, 6:23:48 AM6/17/14
to golan...@googlegroups.com
Can anyone point me to a direction, on how to create a simple web proxy server (supports both http and https) in golang? My use case is like this:

machine A (does not have internet connectivity) -----> machine B (it has internet connectivity) ------> Internet

I am using machine A and I want to install proxy server app in machine B, so that all traffic from A goes to internet via B. A is a windows box and B is a linux one. I don't want to use ssh port forwarding as some applications like (node etc.) does not support socks proxy.

Thanks in advance.

Mat Evans

unread,
Jun 17, 2014, 7:37:24 AM6/17/14
to golan...@googlegroups.com
Hi,

I would definitely start having a look at the net/http/httputil package - it has some functions for proxying web requests - i've used the NewSingleHostReverseProxy(target *url.URL) function with success before. I believe there is some example code on this very board.

Joshua

unread,
Jun 17, 2014, 10:20:23 AM6/17/14
to golan...@googlegroups.com
You can try using this: https://github.com/elazarl/goproxy

Anindya Chatterjee

unread,
Jun 17, 2014, 3:33:46 PM6/17/14
to golan...@googlegroups.com
Let me try that.. At a first glance it looks promising. Thanks for the link.

Regards,

Anindya
Reply all
Reply to author
Forward
0 new messages