Description
goproxy
goproxy is a load-balancing, reverse-proxy server implemented in go, supporting cache( by redis). As a load-balancing server, it supports 4 algorithms: Randomized Algorithm, Weight Round Robin Algorithm, Power of Two Choices (P2C) Algorithm, IP Hash Algorithm, Consistent Hashing with Bounded Loads Algorithm, besides, goproxy can dominate the http requests: filtering and blocking specific requests and even rewriting them.
Sometimes your program needs to call some third party API and wants to customize the responses from it, in that case, goproxy will be your great choice.
Features:
- Supporting reverse-proxy, 6 load-balancing algorithms in goproxy: Random, IP Hash, Round Robin, Weight Round Robin, Power of Two Choices (P2C), Consistent Hashing with Bounded Loads
- Supporting GET/POST/PUT/DELETE Methods in http and CONNECT method in https in goproxy
- Supporting HTTP authentication
- Filtering and blocking specific http requests and even rewriting them in goproxy
- Customizing responses from third-party API
- Cache support with memory or redis to speed up the responding and the expired time of caches is configurable
- Flexible and eager-loading configurations
goproxy alternatives and similar packages
Based on the "Server Applications" category.
Alternatively, view goproxy alternatives based on common mentions on social networks and blogs.
-
Caddy
Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS -
etcd
Distributed reliable key-value store for the most critical data of a distributed system -
consul
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure. -
Vault
A tool for secrets management, encryption as a service, and privileged access management -
apex
Build, deploy, and manage AWS Lambda functions with ease (with Go support!). -
RoadRunner
🤯 High-performance PHP application server, process manager written in Go and powered with plugins -
SFTPGo
Fully featured and highly configurable SFTP server with optional HTTP/S, FTP/S and WebDAV support - S3, Google Cloud Storage, Azure Blob -
Ponzu
Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go. -
Jocko
Kafka implemented in Golang with built-in coordination (No ZK dep, single binary install, Cloud Native) -
Flagr
Flagr is a feature flagging, A/B testing and dynamic configuration microservice -
algernon
:tophat: Small self-contained pure-Go web server with Lua, Markdown, HTTP/2, QUIC, Redis and PostgreSQL support -
discovery
A registry for resilient mid-tier load balancing and failover. -
Trickster
Open Source HTTP Reverse Proxy Cache and Time Series Dashboard Accelerator -
Key Transparency
A transparent and secure way to look up public keys. -
Rendora
dynamic server-side rendering using headless Chrome to effortlessly solve the SEO problem for modern javascript websites -
jackal
💬 Instant messaging server for the Extensible Messaging and Presence Protocol (XMPP). -
Golang API Starter Kit
Go Server/API boilerplate using best practices DDD CQRS ES gRPC -
go-feature-flag
GO Feature Flag is a simple, complete and lightweight feature flag solution 100% Open Source. 🎛️ -
Euterpe
Self-hosted music streaming server 🎶 with RESTful API and Web interface. Think of it as your very own Spotify! ☁️🎧 -
Eru
Eru, a simple, stateless, flexible, production-ready orchestrator designed to easily integrate into existing workflows. Can run any virtualization things in long or short time. -
marathon-consul
Integrates Marathon apps with Consul service discovery. -
cortex-tenant
Prometheus remote write proxy that adds Cortex/Mimir tenant ID based on metric labels -
go-proxy-cache
Simple Reverse Proxy with Caching, written in Go, using Redis. -
lets-proxy2
Reverse proxy with automatically obtains TLS certificates from Let's Encrypt -
Simple CRUD App w/ Gorilla/Mux, MariaDB
Simple CRUD Application with Go, Gorilla/mux, MariaDB, Redis. -
protoxy
A proxy server than converts JSON request bodies to protocol buffers -
simple-jwt-provider
Simple and lightweight provider which exhibits JWTs, supports login, password-reset (via mail) and user management. -
autobd
autobd is an automated, networked and containerized backup solution -
go-fitbit
Fitbit API for Go to fetch, add, update and delete data on Fitbit using REST API -
riemann-relay
Service for relaying Riemann events to Riemann/Carbon destinations
Clean code begins in your IDE with SonarLint
Do you think we are missing an alternative of goproxy or a related project?
README
Engilish|[🇨🇳中文](README_ZH.md)
goproxy
goproxy is a load-balancing, reverse-proxy server implemented in go, supporting cache( in memory or Redis). As a load-balancing server, it supports 4 algorithms: Randomized Algorithm, Weight Round Robin Algorithm, Power of Two Choices (P2C) Algorithm, IP Hash Algorithm, Consistent Hashing with Bounded Loads Algorithm, besides, goproxy can dominate the http requests: filtering and blocking specific requests and even rewriting them.
Sometimes your program needs to call some third party API and wants to customize the responses from it, in that case, goproxy will be your great choice.
🚀 Features:
- Supporting reverse-proxy, 6 load-balancing algorithms in goproxy: Random, IP Hash, Round Robin, Weight Round Robin, Power of Two Choices (P2C), Consistent Hashing with Bounded Loads
- Supporting GET/POST/PUT/DELETE Methods in http and CONNECT method in https in goproxy
- Supporting HTTP authentication
- Filtering and blocking specific http requests and even rewriting them in goproxy
- Customizing responses from third-party API
- Cache support with memory or Redis to speed up the responding and the expired time of caches is configurable
- Flexible and eager-loading configurations
🎉 How to use goproxy
1.Get source code
go get github.com/panjf2000/goproxy
Besides, you also need a Redis to support caching responses if you enable Redis config in goproxy.
2.Compile the source code
cd $GOPATH/src/github.com/panjf2000/goproxy
go build
3.Run
goproxy uses cfg.toml as its configurations file which is located in /etc/proxy/cfg.toml
of your server, you should create a cfg.toml in there previously, here is a typical example:
# toml file for goproxy
title = "TOML config for goproxy"
[server]
port = ":8080"
reverse = true
proxy_pass = ["127.0.0.1:6000"]
# 0 - random, 1 - loop, 2 - power of two choices(p2c), 3 - hash, 4 - consistent hashing
inverse_mode = 2
auth = false
cache = true
cache_timeout = 60
cache_type = "redis"
log = 1
log_path = "./logs"
user = { agent = "proxy" }
http_read_timeout = 10
http_write_timeout = 10
[redis]
redis_host = "localhost:6379"
redis_pass = ""
max_idle = 5
idle_timeout = 10
max_active = 10
[mem]
capacity = 1000
cache_replacement_policy = "LRU"
Configurations:
[server]
- port:the port goroxy will listen to
- reverse:enable the reverse-proxy feature or not
- proxy_pass:back-end servers that actually provide services, like ["127.0.0.1:8010","127.0.0.1:885","127.0.0.1:80882","127.0.0.1:8888"], weight can be assigned to every single server
- inverse_mode:load-balancing algoritms:0 for Randomized Algorithm; 1 for Weight Round Robin Algorithm; 2 for Power of Two Choices (P2C) Algorithm; 3 for IP Hash Algorithm based on hash ring; 4 for Consistent Hashing with Bounded Loads Algorithm
- auth:enable http authentication or not
- cache:enable responses caching or not
- cache_timeout:expired time of responses caching, in seconds
- cache_type: redis or memory
- log:log level, 1 for Debug,0 for info
- log_path:the path of log files
- user:user name from http authentication
- http_read_timeout:duration for waiting response from the back-end server, if goproxy don't get the response after this duration, it will throw an exception
- http_write_timeout:duration for back-end server writing response to goproxy, if back-end server takes a longer time than this duration to write its response into goproxy, goproxy will throw an exception
[redis]
- redis_host:redis host
- redis_pass:redis password
- max_idle:the maximum idle connections of redis connection pool
- idle_timeout:duration for idle redis connection to close
- max_active:maximum size of redis connection pool
[mem]
- capacity: cache capacity of items
- cache_replacement_policy: LRU or LFU
There should be a binary named goproxy
as the same of project name after executing the go build
command and that binary can be run directly to start a goproxy server.
The running goproxy server listens in the port set in cfg.toml and it will forward your http requests to the back-end servers set in cfg.toml by going through that port in goproxy.
🎱 Secondary development
Up to present, goproxy has implemented all basic functionalities like reverse-proxy, load-blancing, http caching, http requests controlling, etc and if you want to customize the responses more accurately, you can implement a new handler by inheriting (not a strict statement as there is no OO in golang) from the ProxyServer struct located in handlers/proxy.go and overriding its method named ServeHTTP, then you are allowed to write your own logic into it.
🙏🏻 Thanks
*Note that all licence references and agreements mentioned in the goproxy README section above
are relevant to that project's source code only.