diff --git a/ansible/roles/traefik/files/docker-compose.yml b/ansible/roles/traefik/files/docker-compose.yml index bb7cade..30e3186 100644 --- a/ansible/roles/traefik/files/docker-compose.yml +++ b/ansible/roles/traefik/files/docker-compose.yml @@ -17,6 +17,7 @@ services: - "{{ private_ip }}:8080:8080" depends_on: - docker_proxy + - nginx networks: - default - traefik @@ -33,6 +34,14 @@ services: networks: - proxy_private + shenanigans: + image: nginx:alpine + restart: unless-stopped + volumes: + - /opt/traefik/nginx.conf:/etc/nginx/conf.d/default.conf:ro + networks: + - proxy_private + networks: traefik: external: true diff --git a/ansible/roles/traefik/files/file-provider-main.yml b/ansible/roles/traefik/files/file-provider-main.yml index 013625a..9db0547 100644 --- a/ansible/roles/traefik/files/file-provider-main.yml +++ b/ansible/roles/traefik/files/file-provider-main.yml @@ -8,3 +8,7 @@ http: headers: customResponseHeaders: Permissions-Policy: interest-cohort=() + + shenanigans: + forwardAuth: + address: http://shenanigans diff --git a/ansible/roles/traefik/files/nginx.conf b/ansible/roles/traefik/files/nginx.conf new file mode 100644 index 0000000..9b40f9e --- /dev/null +++ b/ansible/roles/traefik/files/nginx.conf @@ -0,0 +1,14 @@ +# NOTE: Use `$http_x_forwarded_host` intead of `$host`. + +server { + listen 80 default_server; + + # Get IP correctly + real_ip_header X-Forwarded-For; + set_real_ip_from 0.0.0.0/0; + + # Allow everything through by default + location / { + return 200; + } +} diff --git a/ansible/roles/traefik/files/traefik.yml b/ansible/roles/traefik/files/traefik.yml index e0d0069..1b74ffd 100644 --- a/ansible/roles/traefik/files/traefik.yml +++ b/ansible/roles/traefik/files/traefik.yml @@ -17,6 +17,7 @@ entryPoints: middlewares: - floc-block@file - compress@file + - shenanigans@file tls: certresolver: le domains: diff --git a/ansible/roles/traefik/tasks/main.yml b/ansible/roles/traefik/tasks/main.yml index df0e3ae..2ff67af 100644 --- a/ansible/roles/traefik/tasks/main.yml +++ b/ansible/roles/traefik/tasks/main.yml @@ -106,3 +106,18 @@ - name: fail2ban include: fail2ban.yml when: with_fail2ban + +- name: Check for nginx config + stat: + path: /opt/traefik/nginx.conf + register: nginx_file + become: true + +- name: Create nginx config, if it doesn't exist already + template: + src: files/nginx.conf + dest: /opt/traefik/nginx.conf + mode: "0600" + when: not nginx_file.stat.exists + notify: restart traefik + become: true