Giter Site home page Giter Site logo

docker-haproxy's Introduction

Archived - see https://github.com/pygmystack/haproxy for the replacement

amazee.io haproxy - ARCHIVED

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 tobybellwood avatar twardnw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-haproxy's Issues

Please don't autostart

Forgive me if i've misunderstood the situation or I'm in the wrong repo, but whenever i restart docker I get amazee-haproxy binding 0.0.0.0. I feel like this is bad manners and often conflicts with other applications I'm running.

Screen Shot 2020-08-10 at 15 03 14

Continuously restarting on M1 Mac

When I run pygmy up I get the following, other caontainers work but amazeeio-haptroxy just continuously in a restarting loop

pygmy up
Successfully started dnsmasq
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Successfully started haproxy
Successfully created amazeeio network
Successfully connected haproxy to amazeeio network
Successfully started mailhog
Successfully started ssh-agent
setting up DNS resolution and loopback alias IP, this may require sudo
Successfully configured local resolver
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Identity added: [edited])
Successfully injected ssh key

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.