Package goproxy provides a customizable HTTP proxy library for Go (golang),
It supports regular HTTP proxy, HTTPS through CONNECT, and "hijacking" HTTPS connection using "Man in the Middle" style attack.
The intent of the proxy is to be usable with reasonable amount of traffic, yet customizable and programmable.
net/http
In order to use goproxy, one should set their browser to use goproxy as an HTTP proxy. Here is how you do that in Chrome and in Firefox.
./bin/basiclocalhost:8080
Mailing List
New features will be discussed on the mailing list before their development.
Latest Stable Release
gopkg.in/elazarl/goproxy.v1
Why not Fiddler2?
Fiddler is an excellent software with similar intent. However, Fiddler is not as customizable as goproxy intends to be. The main difference is, Fiddler is not intended to be used as a real proxy.
A possible use case that suits goproxy but not Fiddler, is gathering statistics on page load times for a certain website over a week. With goproxy you could ask all your users to set their proxy to a dedicated machine running a goproxy server. Fiddler is a GUI app not designed to be run like a server for multiple users.
A taste of goproxygoproxy
X-GoProxy: yxorPoG-X
DoFunc
Note that we returned nil value as the response. Had we returned a response, goproxy would have discarded the request and sent the new response to the client.
In order to refuse connections to reddit at work time
DstHostIsReqConditionRequestDstHostIs("www.reddit.com")ReqCondition
DoFunc
See additional examples in the examples directory.
Type of handlers for manipulating connect/req/resp behaviorThere are 3 kinds of useful handlers to manipulate the behavior, as follows:
Depending on what you want to manipulate, the ways to add handlers to each handler list are:
For example:
What's New LicenseI put the software temporarily under the Go-compatible BSD license. If this prevents someone from using the software, do let me know and I'll consider changing it.
At any rate, user feedback is very important for me, so I'll be delighted to know if you're using this package.
Beta SoftwareI've received positive feedback from a few people who use goproxy in production settings. I believe it is good enough for usage.
I'll try to keep reasonable backwards compatibility. In case of a major API change, I'll change the import path.