Skip to content

Commit

Permalink
Docker: Add config file for Traefik in stead of command line options
Browse files Browse the repository at this point in the history
This also adds X-Forwarded-for config so backends see the original ip
address
  • Loading branch information
quartje committed Feb 16, 2024
1 parent c144fd6 commit 1b3e042
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
9 changes: 8 additions & 1 deletion roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
- config
- certs

- name: Place the traefik configuration file
ansible.builtin.template:
src: traefik.yaml.j2
dest: /opt/openconext/traefik/config/traefik.yaml
owner: root
mode: "0640"

- name: Place the dynamic configuration
ansible.builtin.copy:
src: router.yaml
Expand Down Expand Up @@ -78,7 +85,7 @@
restart_policy: "always"
networks:
- name: "loadbalancer"
command: "--providers.docker --providers.docker.network=loadbalancer --entrypoints.websecure.address=:443 --providers.file.directory=/config/config/ --providers.docker.exposedbydefault=false --accesslog=true --ping --serverstransport.insecureskipverify=true"
command: "--configFile=/config/config/traefik.yaml"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/openconext/traefik/:/config/
Expand Down
28 changes: 28 additions & 0 deletions roles/docker/templates/traefik.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
providers:
docker:
exposedByDefault: false
network: loadbalancer
# File provider configuration
file:
directory: /config/config/
watch: true
# EntryPoints configuration
entryPoints:
websecure:
address: ":443"
forwardedHeaders:
trustedIPs:
{% for engine_trusted_proxy_ip in engine_trusted_proxy_ips %}
- {{ engine_trusted_proxy_ip }}
{% endfor %}
# Server transport configuration
serversTransport:
insecureSkipVerify: true
# Enable access log
accessLog: {}
# Enable ping
ping: {}
# Global configuration
global:
checkNewVersion: false
sendAnonymousUsage: false

0 comments on commit 1b3e042

Please sign in to comment.