Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Node Http Proxy | 13,281 | 398,065 | 2,932 | 3 days ago | 103 | May 17, 2020 | 577 | other | JavaScript | |
A full-featured http proxy for node.js | ||||||||||
Whistle | 11,985 | 11 | 17 | a day ago | 539 | September 13, 2022 | 27 | mit | JavaScript | |
HTTP, HTTP2, HTTPS, Websocket debugging proxy | ||||||||||
Hotel | 9,861 | 9 | 7 | 3 months ago | 83 | June 17, 2018 | 124 | mit | JavaScript | |
🏩 A simple process manager for developers. Start apps from your browser and access them using local domains | ||||||||||
Anyproxy | 7,193 | 73 | 131 | a year ago | 176 | June 18, 2020 | 241 | apache-2.0 | JavaScript | |
A fully configurable http/https proxy in NodeJS | ||||||||||
Goproxy | 5,259 | 1,863 | 1,258 | a month ago | July 25, 2018 | 208 | bsd-3-clause | Go | ||
An HTTP proxy library for Go | ||||||||||
Redbird | 4,218 | 75 | 55 | 2 years ago | 67 | December 17, 2019 | 123 | bsd-2-clause | JavaScript | |
A modern reverse proxy for node | ||||||||||
Haproxy | 3,566 | 9 hours ago | 289 | other | C | |||||
HAProxy Load Balancer's development branch (mirror of git.haproxy.org) | ||||||||||
Nginx Tutorial | 3,032 | 2 months ago | 5 | cc-by-sa-4.0 | JavaScript | |||||
这是一个 Nginx 极简教程,目的在于帮助新手快速入门 Nginx。 | ||||||||||
Redsocks | 2,855 | 2 months ago | 1 | February 27, 2018 | 69 | C | ||||
transparent TCP-to-proxy redirector | ||||||||||
Fq Book | 2,675 | 14 days ago | Shell | |||||||
📖《网络代理与VPN应用详解》 详细阐述代理、隧道、VPN运作过程,并对GFW策略如:地址端口封锁、服务器缓存投毒、数字验证攻击、SSL连接阻断做相关的原理说明 |
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.
The proxy itself is simply a net/http
handler.
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.
For example, the URL you should use as proxy when running ./bin/basic
is
localhost:8080
, as this is the default binding for the basic proxy.
New features will be discussed on the mailing list before their development.
Get the latest goproxy from gopkg.in/elazarl/goproxy.v1
.
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.
To get a taste of goproxy
, a basic HTTP/HTTPS transparent proxy
package main
import (
"github.com/elazarl/goproxy"
"log"
"net/http"
)
func main() {
proxy := goproxy.NewProxyHttpServer()
proxy.Verbose = true
log.Fatal(http.ListenAndServe(":8080", proxy))
}
This line will add X-GoProxy: yxorPoG-X
header to all requests sent through the proxy
proxy.OnRequest().DoFunc(
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
r.Header.Set("X-GoProxy","yxorPoG-X")
return r,nil
})
DoFunc
will process all incoming requests to the proxy. It will add a header to the request
and return it. The proxy will send the modified request.
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
proxy.OnRequest(goproxy.DstHostIs("www.reddit.com")).DoFunc(
func(r *http.Request,ctx *goproxy.ProxyCtx)(*http.Request,*http.Response) {
if h,_,_ := time.Now().Clock(); h >= 8 && h <= 17 {
return r,goproxy.NewResponse(r,
goproxy.ContentTypeText,http.StatusForbidden,
"Don't waste your time!")
}
return r,nil
})
DstHostIs
returns a ReqCondition
, that is a function receiving a Request
and returning a boolean.
We will only process requests that match the condition. DstHostIs("www.reddit.com")
will return
a ReqCondition
accepting only requests directed to "www.reddit.com".
DoFunc
will receive a function that will preprocess the request. We can change the request, or
return a response. If the time is between 8:00am and 17:00pm, we will reject the request, and
return a pre-canned text response saying "do not waste your time".
See additional examples in the examples directory.
There are 3 kinds of useful handlers to manipulate the behavior, as follows:
// handler called after receiving HTTP CONNECT from the client, and before proxy establish connection
// with destination host
httpsHandlers []HttpsHandler
// handler called before proxy send HTTP request to destination host
reqHandlers []ReqHandler
// handler called after proxy receives HTTP Response from destination host, and before proxy forward
// the Response to the client.
respHandlers []RespHandler
Depending on what you want to manipulate, the ways to add handlers to each handler list are:
// Add handlers to httpsHandlers
proxy.OnRequest(Some ReqConditions).HandleConnect(YourHandlerFunc())
// Add handlers to reqHandlers
proxy.OnRequest(Some ReqConditions).Do(YourReqHandlerFunc())
// Add handlers to respHandlers
proxy.OnResponse(Some RespConditions).Do(YourRespHandlerFunc())
For example:
// This rejects the HTTPS request to *.reddit.com during HTTP CONNECT phase
proxy.OnRequest(goproxy.ReqHostMatches(regexp.MustCompile("reddit.*:443$"))).HandleConnect(goproxy.AlwaysReject)
// This will NOT reject the HTTPS request with URL ending with gif, due to the fact that proxy
// only got the URL.Hostname and URL.Port during the HTTP CONNECT phase if the scheme is HTTPS, which is
// quiet common these days.
proxy.OnRequest(goproxy.UrlMatches(regexp.MustCompile(`.*gif$`))).HandleConnect(goproxy.AlwaysReject)
// The correct way to manipulate the HTTP request using URL.Path as condition is:
proxy.OnRequest(goproxy.UrlMatches(regexp.MustCompile(`.*gif$`))).Do(YourReqHandlerFunc())
Hijack
CONNECT requests. See
the eavesdropper example
I 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.
I'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.