Giter Site home page Giter Site logo

docker-haproxy's Introduction

amazee.io haproxy

This Images is part of the amazee.io local docker development environment. It provides a haproxy that serves as an reverse proxy in front of multiple Containers. This allows us to access multiple containers via nice URLs without the need to publish or know the ports of the containers.

Usage

When used together with cachalot or pygmy everything is already setup and ready to go. You don't have to worry more.

Start manually

   docker run -d -p 80:80 -p 443:443 --volume=/var/run/docker.sock:/tmp/docker.sock --name=amazeeio-haproxy amazeeio/haproxy

By default this Image will listen to port 80 and 443 for http and https connections. It is not forced though to this, with defining another port this Image also works, example:

   docker run -d -p 8080:80 -p 4443:443 --volume=/var/run/docker.sock:/tmp/docker.sock --name=amazeeio-haproxy amazeeio/haproxy

How it works

The container has docker-gen installed, which listens to the Docker socket for changes of containers.

Every container that has an environment variable AMAZEEIO set, docker-gen will generate from the template (haproxy.tmpl)[./haproxy.tmpl] and haproxy config and restart the haproxy.

Use with non-amazeeio containers

This container can not only be used for Containers started from amazee.io Docker Images, it can reverse proxy any kind of Containers. In order to do so, start your container with the following environment variables:

  • AMAZEEIO - Tells docker-gen that this container should be handled (value does not matter, just use AMAZEEIO=AMAZEEIO)
  • AMAZEEIO_URL - the URL for which connections should be forwarded to by haproxy (if not set, falls back to the Container name. Plus make sure that your DNS resolves the given URL to the IP of the Docker Host)
  • AMAZEEIO_HTTP_PORT - the port were the container listens for HTTP Connections, this port also needs to be exposed via the container (falls back to 80 if not set)
  • AMAZEEIO_HTTPS_PORT - the port were the container listens for HTTPS Connections, this port also needs to be exposed via the container (falls back to 443 if not set)

Example:

    docker run --rm -e AMAZEEIO_URL=nginx.docker.amazee.io -e AMAZEEIO=AMAZEEIO -e AMAZEEIO_HTTP_PORT=80 -p 80 nginx

Problem resolving

The haproxy exposes it's status page on /stats (like: http://docker.amazee.io/stats if used with amazee.io). There you can see the containers, their ports and their URLs for which reverse proxy entries are made.

If something doesn't work at all, run haproxy -f haproxy.cfg -d within the running container (it should be running even if there is an haproxy error), this will start haproxy in debug mode and should show you possible errors.

If all fails, join the amazee.io slack channel at https://slack.amazee.io, we're glad to help.

Development

For easier development, there is an docker-compose.yml file which starts the an container and mounts the template file into the container for easier development.

docker-haproxy's People

Contributors

dasrecht avatar schnitzel avatar twardnw avatar

Watchers

 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.