GithubHelp home page GithubHelp logo

nginx-proxy's Introduction

nginx 1.9.0 License MIT

Nginx Reverse Proxy + DockerSpy

This project implements an nginx balancer capable of automatcly include nodes behind it's reverse proxy as soon as they start on a same docker host. The proxy also can recoginize when one docker node is removed from the cluster. This behavior is guaranteed by DockerSpy app that listen to docker events.

Usage

To start the container run the command as described:

$ docker run -dt --name proxy \
  -e 'PYTHONIOENCODING="utf-8"' \
  -p 80:80 -p 443:443 \
  -v /etc/nginx/certs:/etc/nginx/certs \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /app/templates:/app/templates leopepe/nginx-proxy:1.5

To a more flexible usage export the templates and certs directory containing your SSL certs and custom template files

You can also overwrite the dockerspy parameters and indicate a differente directory to save config files and template source:

$ docker run -dt --name proxy \
  -e 'PYTHONIOENCODING="utf-8"' \
  -e 'ENV DOCKER_HOST="unix://var/run/docker.sock"' \
  -e 'CONFIG_DEST="/etc/nginx/conf.d/"' \
  -e 'TEMPLATE_FILE= "templates/node.nodomain.conf"' \
  ...

Note that the name proxy can also be changed to what suits you best

Recognizing Cluster Members

In due to the nginx-proxy work correctly and recognize the nodes being bringup behind it the containers need to start with two environment variables:

VIRTUAL_HOST: Literally an unique virtual host name (vhost) VIRTUAL_PORT: The port os the service running inside the docker container.

To start the containers "behind" the nginx-proxy:

$ docker run -e VIRTUAL_HOST=node1.nodomain -e VIRTUAL_PORT=8080 ...

Or by setting up the environment variable on the Dockerfile of your containers.

By now the project only supports single PORT services. If you intent to run services using multiple ports this project will not help you. Wait for next version or feel free to extend it.

Credits

This project was based on jwilder/nginx-proxy project

TODO

  • Extract dockerspy from proxy server

nginx-proxy's People

Contributors

leopepe avatar

Watchers

 avatar  avatar  avatar

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.