{"id":18821611,"url":"https://github.com/octu0/revproxy","last_synced_at":"2025-06-25T22:35:42.362Z","repository":{"id":55651432,"uuid":"319664577","full_name":"octu0/revproxy","owner":"octu0","description":"simple and configurable reverse proxy","archived":false,"fork":false,"pushed_at":"2020-12-15T08:47:36.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-22T10:13:15.519Z","etag":null,"topics":["consistent-hashing","http-server","port-mapping","proxy","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/octu0.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}},"created_at":"2020-12-08T14:32:41.000Z","updated_at":"2020-12-17T07:57:32.000Z","dependencies_parsed_at":"2022-08-15T05:31:32.013Z","dependency_job_id":null,"html_url":"https://github.com/octu0/revproxy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/octu0/revproxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Frevproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Frevproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Frevproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Frevproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octu0","download_url":"https://codeload.github.com/octu0/revproxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octu0%2Frevproxy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261964572,"owners_count":23237435,"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":["consistent-hashing","http-server","port-mapping","proxy","reverse-proxy"],"created_at":"2024-11-08T00:44:53.833Z","updated_at":"2025-06-25T22:35:42.337Z","avatar_url":"https://github.com/octu0.png","language":"Go","readme":"# `revproxy`\n\n[![Apache License](https://img.shields.io/github/license/octu0/revproxy)](https://github.com/octu0/revproxy/blob/master/LICENSE)\n[![GoDoc](https://godoc.org/github.com/octu0/revproxy?status.svg)](https://godoc.org/github.com/octu0/revproxy)\n[![Go Report Card](https://goreportcard.com/badge/github.com/octu0/revproxy)](https://goreportcard.com/report/github.com/octu0/revproxy)\n[![Releases](https://img.shields.io/github/v/release/octu0/revproxy)](https://github.com/octu0/revproxy/releases)\n\n`revproxy` provides simple and configurable reverse proxy.\n\nfeatures:\n- [httputil.ReverseProxy](https://golang.org/pkg/net/http/httputil/#ReverseProxy) base HTTP Proxy Server\n- Simple Programable configure\n- Port mapping Proxy\n- URL based Consistent Hashing Proxy\n\n## Download\n\nLinux amd64 / Darwin amd64 binaries are available in [Releases](https://github.com/octu0/revproxy/releases)\n\n## Build\n\nBuild requires Go version 1.13+ installed.\n\n```shell\n$ go version\n```\n\nRun `make pkg` to Build and package for linux, darwin.\n\n```shell\n$ git clone https://github.com/octu0/revproxy\n$ make pkg\n```\n\n# Configure\n\n## Simple Proxy\n\nTo proxy a specific Path, use HandleFunc and Proxy functions\n\n```\n{{ HandleFunc \"/ok\" (Text 200 \"OK\") }}\n{{ HandleFunc \"/foobar1\" (Proxy \"http://targethost:8080/foobar2\") }}\n{{ HandleFunc \"/\" (Proxy \"http://www.google.com/\") }}\n```\n\nIn this configuration, proxy is performed as below:\n\n```\n- http://localhost:8080/         =\u003e proxy http://www.google.com/\n- http://localhost:8080/foobar1  =\u003e proxy http://targethost:8080/foobar2\n- http://localhost:8080/ok       =\u003e response \"OK\"\n```\n\n## Port mapping Proxy\n\nusing the built-in functions and the key/value values set with `--value` when `revproxy` is started,\nproxy specify the port number.\n\nSpecify HandlePrefix to make all paths under specific path to be proxy.\n\n```\n{{ with $path := \"/port-balance/{id:[0-9]+}\" -}}\n  {{- with $url := \"http://{{ hostport .BASE_IP .BASE_PORT .id }}/api/{{ .id }}\" -}}\n  {{ HandlePrefix $path (Proxy $url) }}\n  {{- end -}}\n{{- end }}\n```\n\nIn this configuration, proxy is performed as below:\n\n```\n- http://localhost:8080/port-balance/123 =\u003e proxy http://localhost:8123/api/123\n- http://localhost:8080/port-balance/456 =\u003e proxy http://localhost:8456/api/456\n```\n\n### Example\n\nTry launching it as below:\n\n```shell\n$ revproxy server --value BASE_IP=localhost --value BASE_PORT=8000 -t '{{ with $path := \"/port-balance/{id:[0-9]+}\" -}}\n  {{- with $url := \"http://{{ hostport .BASE_IP .BASE_PORT .id }}/api/{{ .id }}\" -}}\n  {{ HandlePrefix $path (Proxy $url) }}\n  {{- end -}}\n{{- end }}'\n```\n\nDestination server started as below:\n\n```shell\n# server1\n$ revproxy server --port 8123 -t '{{ HandlePrefix \"/api/123\" (Text 200 \"i am :8123/api/123\") }}' \u0026\n\n# server2\n$ revproxy server --port 8456 -t '{{ HandlePrefix \"/api/456\" (Text 200 \"i am :8456/api/456\") }}' \u0026\n```\n\nTry to get the requests distributed.\n\n```shell\n$ curl -XGET localhost:8080/port-balance/123\ni am :8123/api/123\n\n$ curl -XGET localhost:8080/port-balance/456\ni am :8456/api/456\n```\n\n## Consistent Hashing Proxy\n\nProxy routing by path-based consistent hashing is defined as below:\n\n```\n{{ with $path := \"/consistent-hashing/{key}\" -}}\n  {{- $url1 := \"http://{{ .BASE_IP }}:8081/{{ .key }}/\" -}}\n  {{- $url2 := \"http://{{ .BASE_IP }}:8082/{{ .key }}/\" -}}\n  {{- $url3 := \"http://{{ .BASE_IP }}:8083/{{ .key }}/\" -}}\n  {{ HandleFunc $path (ProxyConsistent $url1 $url2 $url3) }}\n{{- end }}\n```\n\nThis will result in the following distribution.\n\n```\n- http://localhost:8080/consistent-hashing/a =\u003e proxy http://localhost:8081/a\n- http://localhost:8080/consistent-hashing/b =\u003e proxy http://localhost:8082/b\n- http://localhost:8080/consistent-hashing/c =\u003e proxy http://localhost:8083/c\n- http://localhost:8080/consistent-hashing/b =\u003e proxy http://localhost:8081/b\n```\n\n### Example\n\nTry launching it as below:\n\n```shell\n### proxy server\n$ revproxy server --value BASE_IP=localhost -t '{{ with $path := \"/consistent-hashing/{key}\" -}}\n\u003e   {{- $url1 := \"http://{{ .BASE_IP }}:8081/{{ .key }}/\" -}}\n\u003e   {{- $url2 := \"http://{{ .BASE_IP }}:8082/{{ .key }}/\" -}}\n\u003e   {{- $url3 := \"http://{{ .BASE_IP }}:8083/{{ .key }}/\" -}}\n\u003e   {{ HandleFunc $path (ProxyConsistent $url1 $url2 $url3) }}\n\u003e {{- end }}'\n```\n\nDestination server started as below:\n\n```shell\n# server1\n$ revproxy server --port 8081 -t '{{ HandlePrefix \"/\" (Text 200 \"i am 8081\") }}' \u0026\n\n# server2\n$ revproxy server --port 8082 -t '{{ HandlePrefix \"/\" (Text 200 \"i am 8082\") }}' \u0026\n\n# server2\n$ revproxy server --port 8083 -t '{{ HandlePrefix \"/\" (Text 200 \"i am 8083\") }}' \u0026\n```\n\nTry to get the requests distributed.\n\n```shell\n$ curl -XGET localhost:8080/consistent-hashing/a\ni am 8081\n\n$ curl -XGET localhost:8080/consistent-hashing/b\ni am 8083\n\n$ curl -XGET localhost:8080/consistent-hashing/c\ni am 8082\n\n$ curl -XGET localhost:8080/consistent-hashing/a\ni am 8081\n```\n\n## Help\n\n```\nNAME:\n   revproxy server\n\nUSAGE:\n   revproxy server [command options] [arguments...]\n\nOPTIONS:\n   --host value                      bind host (default: \"[0.0.0.0]\") [$REVPROXY_HOST]\n   --port value                      bind port (default: 8080) [$REVPROXY_PORT]\n   -t value, --template value        /path/to.tpl reverse proxy router template value or template file path [$REVPROXY_TEMPLATE]\n   --header value                    allow headers\n   --value value, -v value           specify variables to be applied to template, format KEY=Value (e.g. IP=10.16.0.2)\n   --http-read-timeout value         http server read timeout(time-unit: second) (default: 10)\n   --http-write-timeout value        http server write timeout(time-unit: second) (default: 10)\n   --http-idle-timeout value         http server idle timeout(time-unit: second) (default: 30)\n   --http-read-header-timeout value  http server read header timeout(time-unit: second) (default: 15)\n```\n\n## License\n\nApache 2.0, see LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctu0%2Frevproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctu0%2Frevproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctu0%2Frevproxy/lists"}