Add routing for external non-docker websites
This commit is contained in:
parent
44ec2ae197
commit
6bcc37732d
@ -18,6 +18,13 @@
|
|||||||
mode: 0600
|
mode: 0600
|
||||||
notify: reload_traefik
|
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
|
- name: Create Traefik network
|
||||||
docker_network:
|
docker_network:
|
||||||
name: traefik
|
name: traefik
|
||||||
|
40
roles/traefik/templates/external.yml.j2
Normal file
40
roles/traefik/templates/external.yml.j2
Normal 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 %}
|
Loading…
Reference in New Issue
Block a user