{"id":20049525,"url":"https://github.com/weaming/http-proxy","last_synced_at":"2025-10-17T17:27:14.061Z","repository":{"id":128810549,"uuid":"162481236","full_name":"weaming/http-proxy","owner":"weaming","description":null,"archived":false,"fork":false,"pushed_at":"2018-12-22T18:06:52.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T20:45:51.200Z","etag":null,"topics":["client-server","proxy"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weaming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-19T19:23:24.000Z","updated_at":"2018-12-22T18:06:54.000Z","dependencies_parsed_at":"2023-04-17T11:00:57.834Z","dependency_job_id":null,"html_url":"https://github.com/weaming/http-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fhttp-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fhttp-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fhttp-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fhttp-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaming","download_url":"https://codeload.github.com/weaming/http-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241479679,"owners_count":19969489,"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":["client-server","proxy"],"created_at":"2024-11-13T11:50:38.527Z","updated_at":"2025-10-17T17:27:09.014Z","avatar_url":"https://github.com/weaming.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## HTTP Proxy\n\nThe origin purpose is send kinds of protocol data through http protocol,\nthen found forwarding https data without CA is not possible...\n\n## Install\n\n```\ngo get -u github.com/weaming/http-proxy\n```\n\n## Usage\n\n```sh\n$ http-proxy -h\nUsage of http-proxy:\n  -listen string\n    \tlisten host:port (default \":8123\")\n  -server string\n    \tserver host:port, run as client if given\n  -simple\n    \tserve http proxy without client\n\n$ http-proxy  -listen :3128 -simple  # serve http proxy directly\n\n$ http-proxy  # run proxy server\n$ http-proxy -listen :3128 -server $ip:10008  # run proxy client\n ```\n\n## 如何写一个 HTTP 代理\n\n![](https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzaie/rzal8502.gif)\n\n![](https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzaie/rzal8504.gif)\n\n* 只有服务端的透明代理\n  * 问题\n    * 如何做到重写 http 域名\n* CS架构的代理\n  * 客户端和服务器协作，完成流量的传输。整个“服务器、客户端配对”是对外透明的。\n  * 问题\n    * 如何复用客户端到服务器之间的连接\n  * 核心\n    * 如何把进来的请求，以什么格式转化为出去的请求\n    * 如何把进来的响应，以什么格式转化为出去的响应\n  * 请求内容\n    * Schema\n    * Host\n    * Protocol Version\n    * Headers\n    * Body\n  * 响应内容\n    * Status Code\n    * Headers\n    * Body\n  * 转发可能会丢失的头部\n    * Host\n    * IP\n    * Proto (http or https)\n  * [代理服务器应该添加的头部](https://tools.ietf.org/html/rfc7239#section-4)\n    * Forwarded\n      * 标准头部\n      * 格式：`Forwarded: by=\u003cidentifier\u003e; for=\u003cidentifier\u003e; host=\u003chost\u003e; proto=\u003chttp|https\u003e`\n    * X-Forwarded-By\n    * X-Forwarded-For\n    * X-Forwarded-Host\n    * X-Forwarded-Proto\n    * Via\n* 代理类型\n  * forward proxies\n    * implicit\n      * 使用自签证书\n    * explict\n      * must be specifically configured within the client application to shuttle the request\n      * by establishing an `HTTP CONNECT` tunnel\n        * authorize the client saying `HTTP/1.1 200 OK`\n        * client will start streaming TCP packets which are routed through to the remote/upstream server specified in the `CONNECT` verb\n        * `CONNECT` is a hop-by-hop method.\n        * \u003e If you're writing a proxy server, all you need to do for allowing your clients to connect to HTTPS servers is read in the CONNECT request, make a connection from the proxy to the end server (given in the CONNECT request), send the client with a 200 OK reply and then forward everything that you read from the client to the server, and vice versa.\n  * reverse proxies\n* 其他代理软件\n  * Squid\n  * mitmproxy\n  * tinyproxy\n  * Apache Traffic Server\n  * privoxy\n  * nginx\n    * [How to use Nginx as a HTTP/HTTPS proxy server? - Server Fault](https://serverfault.com/questions/298392/how-to-use-nginx-as-a-http-https-proxy-server)\n    * If you want to use an HTTP/HTTPS proxy, you should use Squid. It was written to do exactly that. Nginx was written to act as a reverse proxy and load balancer, but not a forward proxy.\n* 其他特性\n  * 支持更多协议\n    * socks5\n    * socks4\n    * http\n    * https\n  * pac\n  * proxy authentication\n  * bypass list\n  * include origin IP\n* References\n  * [GitHub - smartystreets/cproxy: A simple, explicit forward proxy written in Go to facilitate HTTP CONNECT Tunneling.](https://github.com/smartystreets/cproxy)\n  * [Proxy servers and tunneling | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling)\n  * [apache - CONNECT request to a forward HTTP proxy over an SSL connection? - Stack Overflow](https://stackoverflow.com/questions/6594604/connect-request-to-a-forward-http-proxy-over-an-ssl-connection)\n  * [Debugging problems with the network proxy - The Chromium Projects](https://www.chromium.org/developers/design-documents/network-stack/debugging-net-proxy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fhttp-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaming%2Fhttp-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fhttp-proxy/lists"}