Add routing for external non-docker websites

This commit is contained in:
Kris Lamoureux 2021-04-16 22:44:20 -04:00
parent 44ec2ae197
commit 6bcc37732d
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
2 changed files with 47 additions and 0 deletions

View File

@ -18,6 +18,13 @@
mode: 0600
notify: reload_traefik
- name: Install dynamic non-docker configuration
template:
src: "external.yml.j2"
dest: "{{ traefik_root }}/config/dynamic/{{ item.name }}.yml"
loop: "{{ traefik_external }}"
when: traefik_external is defined
- name: Create Traefik network
docker_network:
name: traefik

View File

@ -0,0 +1,40 @@
http:
routers:
{{ item.name }}:
rule: "Host(`{{ item.domain }}`)"
service: {{ item.name }}-service
{% if item.basicauth is defined and item.middlewares is defined %}
middlewares: "{{ item.middlewares }},{{ item.name }}-auth@file"
{% elif item.basicauth is defined %}
middlewares: "{{ item.name }}-auth@file"
{% elif item.middlewares is defined %}
middlewares: "{{ item.middlewares }}"
{% endif %}
tls:
certResolver: letsencrypt
domains:
- main: "{{ item.domain }}"
entryPoints:
- "websecure"
services:
{{ item.name }}-service:
loadBalancer:
{% if item.httpsbackend is defined %}
serversTransport: {{ item.name }}-httpsbackend
servers:
- url: "{{ item.backend }}"
{% endif %}
{% if item.httpsbackend is defined %}
serversTransports:
{{ item.name }}-httpsbackend:
insecureSkipVerify: true
{% endif %}
{% if item.basicauth is defined %}
middlewares:
{{ item.name }}-auth:
basicAuth:
users:
{% for user in item.basicauth %}
- "{{ user }}"
{% endfor %}
{% endif %}