traefik

URL ändern / hinzufügen

Ändern in docker-compose.yml: traefik.frontend.rule: Host:eineadresse.com,eineandereadresse.com

Dann docker build und docker stack deploy. Oder konkret:

root@server /opt/adtech-demo-webapp # docker build . -t adtech-demo
Sending build context to Docker daemon  35.97MB
Step 1/2 : FROM nginx
 ---> 42b4762643dc
Step 2/2 : COPY dist/ /usr/share/nginx/html
 ---> Using cache
 ---> b2709805037d
Successfully built b2709805037d
Successfully tagged adtech-demo:latest
root@here-ems /opt/adtech-demo-webapp # docker stack deploy -c docker-compose.yml adtech-demo
Ignoring unsupported options: build

Updating service adtech-demo_adtech-demo (id: eyvr8kkwg1n0l0c7leptxu0na)
image adtech-demo:latest could not be accessed on a registry to record
its digest. Each node will access adtech-demo:latest independently,
possibly leading to different nodes running different
versions of the image.

301 redirect

Redirect von einer URL auf andere, zB bei Änderung oder für -www

  • zu redirectende URL muss in traefik.frontend.rule: traefik.frontend.rule: Host:adtech-demo.here-ems.example.com,media-demo.here-ems.example.com
  • außerdem muss rein:
traefik.frontend.redirect.regex: ^https://adtech-demo.here-ems.example.com/(.*)$$
traefik.frontend.redirect.replacement: https://media-demo.here-ems.example.com/$$1
traefik.frontend.redirect.permanent: 'true'

Letzteres, weils per dafult 302er macht und nicht 301.