An HTTP proxy server package
An HTTP proxy package for intercepting, modifying traffic and forwarding it via a reverse proxy server (like HAproxy).
This package is extended upon elazarl's goproxy. Full functionality of it can be access through GoProxy
variable, But ctx.UserData
must not be altered.
package main
import (
"flag"
"log"
"net/http"
"net/url"
"github.com/elazarl/goproxy"
"github.com/rahulwa/camouflage/proxy"
)
func init() {
rProxyServer, err := url.Parse("http://127.0.0.1:8081")
if err != nil {
log.Fatal("main: init: unable to parse reverseproxyadress")
}
proxy.Conf = &proxy.Config{
RedisControllerChannel: "proxiesChannel",
ReverseProxyServer: *rProxyServer,
ProxyPort: 8080,
MetricPort: 9099,
Verbose: false,
DumpInWireFormat: false,
}
flag.Parse()
}
func main() {
// This line will add X-GoProxy: yxorPoG-X header to all requests sent through the proxy.
proxy.GoProxy.OnRequest().DoFunc(
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
r.Header.Set("X-GoProxy","yxorPoG-X")
return r,nil
})
// Start the proxy server
proxy.Proxy(nil, nil)
}
For more example, see examples directory and documentation.
X-Camouflage-Context
header on response.