Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miguelgrinberg/easy-lb-nginx
Simple load balancer container based on nginx, confd and etcd
https://github.com/miguelgrinberg/easy-lb-nginx
confd etcd load-balancer nginx
Last synced: 19 days ago
JSON representation
Simple load balancer container based on nginx, confd and etcd
- Host: GitHub
- URL: https://github.com/miguelgrinberg/easy-lb-nginx
- Owner: miguelgrinberg
- License: mit
- Created: 2017-03-06T05:59:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-13T02:36:15.000Z (almost 8 years ago)
- Last Synced: 2024-05-23T09:02:15.755Z (8 months ago)
- Topics: confd, etcd, load-balancer, nginx
- Language: Shell
- Size: 2.46 MB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# easy-lb-nginx
Simple load balancer container for Docker, based on nginx, confd and etcd.
## High-level design
The container runs an [nginx](https://www.nginx.com/resources/wiki/) load balancer process. The configuration is generated by [confd](https://github.com/kelseyhightower/confd) from live data pulled from [etcd](https://github.com/coreos/etcd). Changes made in etcd are automatically reflected in the configuration, making it very convenient for services to add and remove themselves from the system just by interacting with the etcd service.
## Deployment
To deploy a load balancer container, use the following command:
docker run -p 80:80 -e ETCD_PEERS=http://172.17.0.2:2379,http://172.17.0.3:2379 miguelgrinberg/easy-lb-nginx
The `ETCD_PEERS` variable is a comma-separated list of URLs for the etcd service, which must be deployed separately. This variable is required.
## Building
To build the container image locally, you can use the included `build.sh` script.
## Configuration
The load balancer is automatically configured from the contents of etcd's `/services` directory. For example, consider the following `etcdctl` commands:
etcdctl set /services/foo/upstream/server1 172.17.0.4:5000
etcdctl set /services/foo/upstream/server2 172.17.0.5:5000
etcdctl set /services/bar/upstream/server3 172.17.0.6:5000This will cause the load balancer to proxy requests to `/foo/...` URLs to server1 and server2, at the addresses and ports specified, while any requests to `/bar/...` URLs will be sent to server3. Note that the names `server{1,2,3}` are not significant, each service can register itself with any name, as long as it is unique.
To mount a service on a different URL, set a `location` key. For example, the following command will make service `foo` available on the root URL:
etcdctl set /services/foo/location /
To use a custom path in the proxied URLs, set a `path` key. For example, the following command will make nginx send requests to the `foo` service to `/api/foo/...` URLs:
etcdctl set /services/foo/path /api/foo/
Whenever changes are made in etcd to the `/services` subtree, those changes will automatically trigger a configuration update.
## TODO
- SSL support
- Automatic Let's Encrypt certificates
- Select load balancing method for each service
- WebSocket proxying
- Configure other options in location or upstream blocks