{"id":18765838,"url":"https://github.com/yeqown/fasthttp-reverse-proxy","last_synced_at":"2025-05-15T22:11:55.617Z","repository":{"id":40523110,"uuid":"156645213","full_name":"yeqown/fasthttp-reverse-proxy","owner":"yeqown","description":"reverse http / websocket proxy based on fasthttp","archived":false,"fork":false,"pushed_at":"2025-04-16T21:51:40.000Z","size":726,"stargazers_count":226,"open_issues_count":1,"forks_count":56,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-21T08:56:23.926Z","etag":null,"topics":["fasthttp","go","http-proxy","lib","reverse-proxy","websocket-proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeqown.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-08T03:31:05.000Z","updated_at":"2025-04-15T18:03:52.000Z","dependencies_parsed_at":"2025-03-18T23:45:31.692Z","dependency_job_id":null,"html_url":"https://github.com/yeqown/fasthttp-reverse-proxy","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Ffasthttp-reverse-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Ffasthttp-reverse-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Ffasthttp-reverse-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeqown%2Ffasthttp-reverse-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeqown","download_url":"https://codeload.github.com/yeqown/fasthttp-reverse-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430331,"owners_count":22069909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fasthttp","go","http-proxy","lib","reverse-proxy","websocket-proxy"],"created_at":"2024-11-07T18:37:05.238Z","updated_at":"2025-05-15T22:11:55.595Z","avatar_url":"https://github.com/yeqown.png","language":"Go","readme":"# fasthttp-reverse-proxy\n![](https://img.shields.io/badge/LICENSE-MIT-blue.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/yeqown/fasthttp-reverse-proxy/v2)](https://goreportcard.com/report/github.com/yeqown/fasthttp-reverse-proxy/v2) [![GoReportCard](https://godoc.org/github.com/yeqown/fasthttp-reverse-proxy/v2?status.svg)](https://godoc.org/github.com/yeqown/fasthttp-reverse-proxy/v2)\n\nreverse http proxy handler based on fasthttp.\n\n## Features\n\n- [x] `HTTP` reverse proxy based [fasthttp](https://github.com/valyala/fasthttp)\n  \n\t- [x] it's faster than golang standard `httputil.ReverseProxy` library.\n\t- [x] implemented by `fasthttp.HostClient` \n\t- [x] support balance distribute based `rounddobin`\n\t- [x] `HostClient` object pool with an overlay of fasthttp connection pool.\n\n* [x] `WebSocket` reverse proxy.\n\n## Get started\n\n#### [HTTP (with balancer option)](./examples/fasthttp-reverse-proxy-with-bla/proxy.go)\n\n```go\nvar (\n\tproxyServer = proxy.NewReverseProxy(\"localhost:8080\")\n\n\t// use with balancer\n\t// weights = map[string]proxy.Weight{\n\t// \t\"localhost:8080\": 20,\n\t// \t\"localhost:8081\": 30,\n\t// \t\"localhost:8082\": 50,\n\t// }\n\t// proxyServer = proxy.NewReverseProxy(\"\", proxy.WithBalancer(weights))\n\n)\n\n// ProxyHandler ... fasthttp.RequestHandler func\nfunc ProxyHandler(ctx *fasthttp.RequestCtx) {\n\t// all proxy to localhost\n\tproxyServer.ServeHTTP(ctx)\n}\n\nfunc main() {\n\tif err := fasthttp.ListenAndServe(\":8081\", ProxyHandler); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n#### [Websocket](./examples/ws-fasthttp-reverse-proxy/README.md)\n\n```go\nvar (\n\tproxyServer *proxy.WSReverseProxy\n\tonce        sync.Once\n)\n\n// ProxyHandler ... fasthttp.RequestHandler func\nfunc ProxyHandler(ctx *fasthttp.RequestCtx) {\n\tonce.Do(func() {\n\t\tvar err error\n\t\tproxyServer, err = proxy.NewWSReverseProxyWith(\n\t\t\tproxy.WithURL_OptionWS(\"ws://localhost:8080/echo\"),\n\t\t\t// [OPTIONAL]: you can override path from `WithURL_OptionWS`\n\t\t\t//             by providing WithDynamicPath_OptionWS.\n\t\t\tproxy.WithDynamicPath_OptionWS(true, proxy.DefaultOverrideHeader),\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t})\n\n\tswitch string(ctx.Path()) {\n\tcase \"/echo\":\n\t\t// [OPTIONAL]: you can override path from `WithURL_OptionWS`\n\t\t//             by providing proxy.DefaultOverrideHeader (or any custom) header  \n\t\t// ctx.Request.Header.Set(proxy.DefaultOverrideHeader, \"/real_echo\")\n\t\tproxyServer.ServeHTTP(ctx)\n\tcase \"/\":\n\t\tfasthttp.ServeFileUncompressed(ctx, \"./index.html\")\n\tdefault:\n\t\tctx.Error(\"Unsupported path\", fasthttp.StatusNotFound)\n\t}\n}\n\nfunc main() {\n\tlog.Println(\"serving on: 8081\")\n\tif err := fasthttp.ListenAndServe(\":8081\", ProxyHandler); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n\n## Usages\n\n* [HTTP reverse proxy](./examples/fasthttp-reverse-proxy/proxy.go)\n* [HTTP reverse proxy with object pool](./examples/fasthttp-reverse-proxy-with-pool/pool.go)\n* [Websocket reverse proxy](./examples/ws-fasthttp-reverse-proxy)\n\n## Contrast\n\n* [HTTP benchmark](./docs/http-benchmark.md)\n* [Websocket benchmark](./docs/ws-benchmark.md)\n\n## References\n\n* [fasthttp](https://github.com/valyala/fasthttp)\n* [standard httputil.ReverseProxy](https://golang.org/pkg/net/http/httputil/#ReverseProxy)\n* [fasthttp/websocket](https://github.com/fasthttp/websocket)\n* [koding/websocketproxy](https://github.com/koding/websocketproxy)\n\n## Thanks\n\n\u003ca href=\"https://www.jetbrains.com/?from=fasthttp-reverse-proxy\" _blank=\"#\"\u003e\n    \u003cimg src=\"https://www.jetbrains.com/company/brand/img/jetbrains_logo.png\" width=\"100\" alt=\"JetBrains\"/\u003e\n\u003c/a\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeqown%2Ffasthttp-reverse-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeqown%2Ffasthttp-reverse-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeqown%2Ffasthttp-reverse-proxy/lists"}