Skip to content

Examplary docker-compose setup for Træfik with letsencrypt.org

License

Notifications You must be signed in to change notification settings

KirkwallDay/reverse-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motivation

Docker-compose setup for starting Træfik as reverse-proxy, loadbalancer and SSL server with lets-encrypt certificates.

Usage

Clone this repository reverse-proxy, change mail-address and domain, and then run docker-compose up -d to startup the service.

git clone https://github.com/docker-compose-examples/reverse-proxy
cd reverse-proxy
# Run `sed` or edit `traefik.toml` yourself
sed -i 's/letsencrypt\@example\.com/[email protected]/g' traefik.toml
sed -i 's/example\.com/my-domain.com/g' traefik.toml 
# Start the reverse proxy
docker-compose up -d

After that, you can "up" docker-compose.yml-files like:

version: '2'

services:
  microbot:
    image: dontrebootme/microbot
    labels:
    - "traefik.enable=true"
    - "traefik.backend=microbot"
    - "traefik.frontend.rule=Host:microbot.example.com"
    - "traefik.docker.network=reverseproxy_default"
    networks:
    - "reverseproxy_default"
    restart: always
networks:
  reverseproxy_default:
    external:
      name: reverseproxy_default

and they will be served through the Træfik proxy.

  • Træfik will forward requests to https://microbot.example.com to the backend.
  • Træfik will order SSL certificates through letsencrypt.org
  • Træfik will balance the requests between multiple backends with the same name, which means additional instance created by docker-compose scale microbot=3 will automatically be used when available.
  • Requests to http://microbot.example.com will be redirected to https

Some details

  • The label traefik.frontend.rule=Host:microbot.example.com is used by Træfik to determine which container to use for which domain.
  • The option exposedbydefault = false tells Træfik to only include containers with the label traefik.enable=true.
  • Since the gist-files are inside the directory reverse-proxy, docker-compose will create a network reverseproxy_default for the container. The part
  networks:
    - "reverseproxy_default"

and

networks:
  reverseproxy_default:
    external:
      name: reverseproxy_default

of the microbot-file make sure that microbot is in the same network as Træfik.

If microbot were present in two networks, the label traefik.docker.network=reverseproxy_default will tell Træfik which IP to use to connect to the service.

LICENSING

All files are mostly derived from each sofware's documentation. Treat this example as public domain (CC0). It took a while to get it running, but the amount of work was not high enough to put it under any license.

Contributing

If you want to help out in keeping this repository up-to-date, please contact me or add a comment here

About

Examplary docker-compose setup for Træfik with letsencrypt.org

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published