Public Repository

Last pushed: 2 years ago
Short Description
Nginx reverse proxy using consul-template
Full Description

Nginx reverse proxy using consul-template. This reverse proxy can be used to provide access to services that live on a Docker swarm cluster. Service registration and service discovery works by deploying one instance of the Kidibox Registrator per overlay network per Docker swarm node.

This image needs a consul template file to be present at /templates/service.ctmpl. Furthermore the image needs to connect to consul (default via the name consul). You can customize this setting using the environment variable $CONSUL_URL
The reverse proxy is a member of the same overlay network as the service(s) it provides access to. At the front end side port 80 and port 443 are exposed.

## Example run command:
docker run -d \
-e CONSUL_URL=$(docker-machine ip c-node-1):8500 \
-p 80:80 \
-p 443:443 \
--net vdnet1 \
--volume /home/dock-adm/service.ctmpl:/templates/service.ctmpl \

## Example service.ctmpl file:
# Consul Template Nginx Reverse Proxy

# Start Nginx-service #
upstream nginx-service {
{{range service "nginx-80"}}server {{.Address}}:{{.Port}} max_fails=3 fail_timeout=60 weight=1;
{{else}}server; # force a 502{{end}}
# End Nginx-service #

# Start server config #
server {
listen 80 default_server;

underscores_in_headers on;
charset utf-8;

location / {
proxy_pass http://nginx-service;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect http://nginx-service/ /;

# End server config #

Docker Pull Command