Coder Social home page Coder Social logo

nginx-confd-etcd's Introduction

nginx-confd-etcd

Dockerfile

Docker container for confd configured nginx based on etcd values generated by Registrator. Mainly for CoreOS cluster.

I started with DigitalOcean's Confd and Etcd but I don't like the idea of sidekick instance. I changed sidekick to Registrator and make some changes in Confd configuration.

Pre-Requirements for cluster configuration

This docker image made for CoreOs cluster. (Detailed cluster setup soon.) You need working Registrators on every cluster nodes and need to create docker Fleet units named with domain name and instance. For example if you would like to run a Wordpress unit you need to name the docker instance to 'wordpress.example.com'.

docker run --name wordpress.example.com --link some-mysql:mysql -p 80 -d wordpress

Registrator will create a key for 'wordpress.example.com' docker instance at '/services/wordpress/core01.mycluster.com:wordpress.example.com:80' with the IP address of the docker instance and port of the Wordpress. For example: '8.8.8.8:49158'

How to use this image

docker run --name nginx.example.com -p 80:80 -e NGINX_BACKEND_SERVICE=example.com -e NGINX_DEMO_DOMAIN=my-demo-domain.com -e HOST_IP=8.8.8.8 tarhelypark/nginx-confd-etcd

The following environment variables available:

  • -e NGINX_BACKEND_SERVICE=... (name of backend service instance, example.com in our example)
  • -e NGINX_DEMO_DOMAIN=... (demo domain name which also forwarded to backend. If you specify y-demo-domain.com example.y-demo-domain.com will be forwarded to example.com)
  • -e HOST_IP=... (IP of etcd)
  • -e ETCD_PORT=... (public port of etcd default: 4001)
  • -e NGINX_WORKER_PROCESSES=... (number of nginx worker processes, default: cpu x 2)

Fleet config

Following configuration will start Nginx on every machine on the cluster and dinamicaly create configuration and proxy routing to every working Wordpress (or any other) instance.

[Unit]
Description=Nginx proxy and load balancer
After=docker.service
After=etcd.service

[Service]
TimeoutStartSec=0

# Get CoreOS environmental variables
EnvironmentFile=/etc/environment

ExecStartPre=-/usr/bin/docker kill %p.%i
ExecStartPre=-/usr/bin/docker rm %p.%i
ExecStartPre=/usr/bin/docker pull tarhelypark/nginx-confd-etcd
ExecStart=/usr/bin/docker run --name %p.%i -p ${COREOS_PUBLIC_IPV4}:80:80 -e NGINX_BACKEND_SERVICE=%i -e NGINX_DEMO_DOMAIN=tarhelypark.hu -e HOST_IP=${COREOS_PUBLIC_IPV4} tarhelypark/nginx-confd-etcd
ExecStop=/usr/bin/docker stop %p.%i

[X-Fleet]
Global=true

Usefull links

nginx-confd-etcd's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.