Nixy is a daemon that automatically configures Nginx for web services deployed on Apache Mesos and Marathon. It's an evolution of moxy but with a greatly improved feature set thanks to the Nginx reverse proxy.
Features:
- Reverse proxy and load balancer for your microservices running inside Mesos and Marathon
- Single binary with no other dependencies (except Nginx/Openresty)
- Written in Go to be blazingly fast and concurrent.
- All the features you get with Nginx:
- HTTP/TCP load balancing, HTTP/2 termination, websockets, SSL/TLS termination, caching/compression, authentication, media streaming, static file serving, etc.
- Zero downtime with Nginx fallback mechanism for sick backends and hot config reload.
- Easy to customize with templating.
- Statistics via statsd (successfull/failed updates, timings).
- Real-time updates via Marathon's event stream (Marathon v0.9.0), no need for callbacks.
- Support for Marathon HA cluster, auto detects sick endpoints.
- Automatic service discovery of all running tasks inside Mesos/Marathon, including health status.
- Basic auth support.
- Health check probe for errors in template or nginx configuration.
All versions of Marathon >= v0.9.0
- Install nixy from pre-compiled packages. Check
releases
page. - Edit config (default on ubuntu is /etc/nixy.toml):
# nixy listening port port = "6000" # optional X-Proxy header name xproxy = "hostname" # marathon api marathon = ["http://example01:8080", "http://example02:8080"] # add all HA cluster nodes in priority order. user = "" # leave empty if no auth is required. pass = "" # nginx nginx_config = "/etc/nginx/nginx.conf" nginx_template = "/etc/nginx/nginx.tmpl" nginx_cmd = "nginx" # optinally openresty # statsd settings statsd = "localhost:8125" # optional for statistics
- Optionally edit the nginx template (default on ubuntu is /etc/nginx/nginx.tmpl)
- Install nginx or openresty and start the service.
- Start nixy! (service nixy start)
Routing is based on the HTTP Host header matching app name by default.
This is easy to change and customize to your own choosing by editing the nginx.tmpl file. For example if you prefer routing based on uri instead of subdomains.
Example to access your apps app1,app2,app3 running inside Mesos and Marathon:
curl -i localhost/ -H 'Host: app1.example.com'
curl -i localhost/ -H 'Host: app2.example.com'
curl -i localhost/ -H 'Host: app3.example.com'
Assuming you have configured nginx on port 80.
Deploy your app to Marathon setting a custom label called subdomain
:
"labels": {
"subdomain": "foobar"
},
This will override the application name and replace it with foobar
as the new subdomain/host-header.
GET /
prints nixy versionGET /v1/config
list all variables available inside the templateGET /v1/reload
trigger a config regenGET /v1/health
Responds 200 OK if template AND config is ok, else 500 Server Error with error message.