Route Nextcloud through Traefik

This commit is contained in:
Kris Lamoureux 2020-07-11 03:38:45 -04:00
parent c630af67cd
commit d851c852d6
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
4 changed files with 27 additions and 6 deletions

View File

@ -1,3 +1,10 @@
# docker
docker_user: vagrant
# traefik
traefik_domain: traefik.vm.krislamo.org
traefik_auth: admin:$apr1$T1l.BCFz$Jyg8msXYEAUi3LLH39I9d1 # admin:admin
# container settings
nextcloud_version: stable
nextcloud_admin: admin

View File

@ -6,4 +6,5 @@
roles:
- base
- docker
- traefik
- nextcloud

View File

@ -4,12 +4,19 @@
"{{ nextcloud_dbroot }}"]
state: directory
- name: Create Nextcloud network
docker_network:
name: "{{ nextcloud_container }}"
- name: Start Nextcloud's database container
docker_container:
name: "{{ nextcloud_dbcontainer }}"
image: mariadb:{{ nextcloud_dbversion }}
restart_policy: always
volumes: "{{ nextcloud_dbroot }}:/var/lib/mysql"
networks_cli_compatible: true
networks:
- name: "{{ nextcloud_container }}"
env:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "{{ nextcloud_dbname }}"
@ -22,8 +29,14 @@
image: nextcloud:{{ nextcloud_version }}
restart_policy: always
volumes: "{{ nextcloud_root }}:/var/www/html"
ports: 80:80
links: "{{ nextcloud_dbcontainer }}:mysql"
networks_cli_compatible: true
networks:
- name: "{{ nextcloud_container }}"
- name: traefik
labels:
traefik.http.routers.nextcloud.rule: "Host(`{{ nextcloud_domain }}`)"
traefik.docker.network: traefik
traefik.enable: "true"
- name: Grab Nextcloud container information
docker_container_info:
@ -32,7 +45,7 @@
- name: Wait for Nextcloud to become available
wait_for:
host: "{{ nextcloud_info.container.NetworkSettings.IPAddress }}"
host: "{{ nextcloud_info.container.NetworkSettings.Networks.traefik.IPAddress }}"
port: 80
- name: Check Nextcloud status

View File

@ -6,7 +6,7 @@
- name: Create Traefik network
docker_network:
name: traefik-net
name: traefik
- name: Start Traefik container
docker_container:
@ -18,13 +18,13 @@
ports: "{{ traefik_ports }}"
networks_cli_compatible: "false"
networks:
- name: "traefik-net"
- name: traefik
labels:
traefik.http.routers.traefik.rule: "Host(`{{ traefik_domain }}`)"
traefik.http.middlewares.auth.basicauth.users: "{{ traefik_auth }}"
traefik.http.routers.traefik.middlewares: "auth@docker"
traefik.http.routers.traefik.service: "api@internal"
traefik.docker.network: "proxy_traefik-net"
traefik.docker.network: traefik
traefik.enable: "true"
volumes:
- /var/run/docker.sock:/var/run/docker.sock