Skip to content

Instantly share code, notes, and snippets.

@danggrianto
Last active April 19, 2020 04:04
Show Gist options
  • Save danggrianto/6c6408e7b6995aa5f13243e96a70dda1 to your computer and use it in GitHub Desktop.
Save danggrianto/6c6408e7b6995aa5f13243e96a70dda1 to your computer and use it in GitHub Desktop.
Installing Traefik on raspberry pi using docker + ansible https://blog.anggrianto.dev/installing-traefik-on-raspberry-pi/
version: '3'
services:
traefik:
image: traefik:v2.2
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik.yml:/traefik.yml:ro
- ./acme.json:/acme.json
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`example.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=username:password"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`example.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=http"
- "traefik.http.routers.traefik-secure.service=api@internal"
networks:
proxy:
external: true
---
- name: Add Traefik
hosts: traefik
tasks:
- name: Copy file to a remote machine
copy:
src: ./files/
dest: ~/traefik
mode: preserve
- name: Create a network
docker_network:
name: proxy
- name: Tear down existing services
docker_compose:
project_src: traefik
state: absent
- name: Create and start services
docker_compose:
project_src: traefik
register: output
api:
dashboard: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
watch: true
certificatesResolvers:
http:
acme:
email: your-email@email.com
storage: acme.json
httpChallenge:
entryPoint: http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment