From 1bc8338234db41761754ef515b495732d30b6ccf Mon Sep 17 00:00:00 2001 From: Joao Magalhaes Date: Sat, 20 Aug 2022 18:33:33 +0000 Subject: [PATCH] Added portainer example --- README.md | 6 +- .../docker-compose-portainer-app-example.yml | 34 +++++++++++ examples/docker/docker-compose-portainer.yml | 59 +++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 examples/docker/docker-compose-portainer-app-example.yml create mode 100644 examples/docker/docker-compose-portainer.yml diff --git a/README.md b/README.md index 7320e43..f239dff 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Important: easyhaproxy needs to be in the same network of the containers or othe | easyhaproxy.[definition].ssl | (Optional) If `true` you need to provide certificate as a file. See below. Do not use with `sslcert`. | true | | easyhaproxy.[definition].health-check | (Optional) `ssl`, enable health check via SSL in `mode tcp` (Defaults to "empty") | ssl | | easyhaproxy.[definition].letsencrypt | (Optional) Generate certificate with letsencrypt. Do not use with `sslcert`. | true OR yes OR false OR no | -| easyhaproxy.[definition].redirect-ssl | (Optional) Redirect all requests to https | true OR yes OR false OR no | +| easyhaproxy.[definition].redirect_ssl | (Optional) Redirect all requests to https | true OR yes OR false OR no | ### Defining the labels in Docker Swarm @@ -221,7 +221,7 @@ easymapping: containers: - container:5000 letsencrypt: true - redirect-ssl: true + redirect_ssl: true host2.com.br: containers: - other:3000 @@ -233,7 +233,7 @@ easymapping: host1.com.br: containers: - container:80 - redirect-ssl: false + redirect_ssl: false ssl: true - port: 8080 diff --git a/examples/docker/docker-compose-portainer-app-example.yml b/examples/docker/docker-compose-portainer-app-example.yml new file mode 100644 index 0000000..8db4c69 --- /dev/null +++ b/examples/docker/docker-compose-portainer-app-example.yml @@ -0,0 +1,34 @@ +# To test: +# curl -k -H "Host: host1.local" https://127.0.0.1/ +# curl -k -H "Host: host2.local" https://127.0.0.1/ +# +# curl -I -H Host:host1.local http://127.0.0.1 +# HTTP/1.1 301 Moved Permanently +# content-length: 0 +# location: https://host1.local/ +# +# curl -I -H Host:host2.local http://127.0.0.1 +# HTTP/1.1 301 Moved Permanently +# content-length: 0 +# location: https://host1.local/ +# +# Test SSL: +# openssl s_client -showcerts -connect 127.0.0.1:443 --servername host1.local + +version: "3" + +services: + container: + image: byjg/static-httpserver + labels: + easyhaproxy.http.redirect_ssl: true + easyhaproxy.http.host: test.xpto.us + easyhaproxy.http.port: 80 + easyhaproxy.http.localport: 8080 + easyhaproxy.http.letsencrypt: true + + +networks: + default: + name: easyhaproxy + external: true diff --git a/examples/docker/docker-compose-portainer.yml b/examples/docker/docker-compose-portainer.yml new file mode 100644 index 0000000..83a7b5c --- /dev/null +++ b/examples/docker/docker-compose-portainer.yml @@ -0,0 +1,59 @@ +# docker volume create certs_letsencrypt +# docker volume create certs_haproxy +# docker volume create portainer_data +# docker network create easyhaproxy + + +version: "3" + +services: + easyhaproxy: + image: byjg/easy-haproxy:master + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - certs_letsencrypt:/certs/letsencrypt +# - certs_haproxy:/certs/haproxy + + environment: + EASYHAPROXY_DISCOVER: docker + EASYHAPROXY_LABEL_PREFIX: easyhaproxy + EASYHAPROXY_LETSENCRYPT_EMAIL: changeme@example.org + EASYHAPROXY_SSL_MODE: "default" + HAPROXY_CUSTOMERRORS: "true" + HAPROXY_USERNAME: admin + HAPROXY_PASSWORD: password + HAPROXY_STATS_PORT: 1936 + + ports: + - "80:80/tcp" + - "443:443/tcp" + - "1936:1936/tcp" + + portainer: + image: portainer/portainer-ce:latest + volumes: + - portainer_data:/data portainer + - /var/run/docker.sock:/var/run/docker.sock + labels: + easyhaproxy.http.redirect_ssl: true + easyhaproxy.http.letsencrypt: true + easyhaproxy.http.host: portainer.xpto.us + easyhaproxy.http.port: 80 + easyhaproxy.http.localport: 9000 + + +volumes: + certs_letsencrypt: + external: true + certs_haproxy: + external: true + portainer_data: + external: true + + +networks: + default: + name: easyhaproxy + external: true + +