Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete Docu #1091

Closed
Berndinox opened this issue Feb 1, 2017 · 15 comments
Closed

Incomplete Docu #1091

Berndinox opened this issue Feb 1, 2017 · 15 comments

Comments

@Berndinox
Copy link

Berndinox commented Feb 1, 2017

What version of Traefik are you using (traefik version)?

docker - traefik:latest

What is your environment & configuration (arguments, toml...)?

Trafik (proxy.yaml)

version: "3.0"

services:
  traefik:
    image: traefik
    networks:
     - proxy
    command: --web --docker.swarmmode --docker.domain=berndklaus.at --docker.watch --docker.endpoint=unix://var/run/docker.sock
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      #- ./traefik.toml:/etc/traefik/traefik.toml
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == manager


networks:
  proxy:
    external: true

WhoamI (whoami.yaml)

networks:
  proxy:
    external: true
root@swarm1:~# cat whoami.yaml
version: "3"
services:
  web:
    image: emilevauge/whoami
    networks:
      - proxy
    deploy:
      labels:
        - "traefik.port=80"
        - "traefik.docker.network=proxy"
        - "traefik.frontend.rule=Host:whoami.berndklaus.at"
      replicas: 3

networks:
  proxy:
    external: true

What i wanna do:

Would like to enable SSL (Letsencrypt Support).

I'm new to traefik, and i do miss information:

  • on howto add an costum configuration (.toml) within a docker compose swarm
  • list of commands available. (I'm not able to exec into the container)
  • do i need a costum configuration to enable Letsencrypt?
  • if i do use a costum config, does the from docker backend generated config changes extend the costum config or otherwrite them?

May someone can help me ;)

@raarts
Copy link

raarts commented Feb 7, 2017

I am having the exact same problem. How to enable letsencrypt with a docker deploy setup?

@raarts
Copy link

raarts commented Feb 7, 2017

I found an example here #750, (specifying options on the traefik commandline) but it would require traefik to be restarted when adding a letsencrypt domain.

@raarts
Copy link

raarts commented Feb 7, 2017

Ok, I got it to work with the following config:

version: "3"
services:
  proxy:
    image: traefik
    command: \
  --web --docker --docker.swarmmode --docker.domain=docker.localhost --docker.watch \
  --logLevel=DEBUG \
  --entryPoints='Name:http Address::80 Redirect.EntryPoint:https' \
  --entryPoints='Name:https Address::443 TLS' \
  --acme.entryPoint=https --acme.email=ron.arts@xxxxxx.com \
  --acme.storage=/etc/traefik/acme/acme.json \
  --acme.domains=xxxxxx.com \
  --acme.ondemand=true \
  --acme.onhostrule=true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - traefikdata:/etc/traefik/acme
    deploy:
      placement:
        constraints:
          - node.labels.env == prod
          - node.role == manager

volumes:
  traefikdata:
    driver: local-persist
    driver_opts:
      mountpoint: /data/traefik

networks:
  proxy:
    driver: overlay

Though, auto-redirect from 80 to 443 doesn't work yet.

@raarts
Copy link

raarts commented Feb 7, 2017

Alright, auto-redirect works if you specify deploy labels like this:

  viz:
    image: manomarks/visualizer
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      proxy:
        aliases:
         - monitor_viz
    deploy:
      labels:
        - traefik.port=8080
        - traefik.backend=monitor_viz
        - traefik.docker.network=proxy
        - traefik.frontend.rule=Host:viz.xxxxx.com
        - traefik.frontend.entryPoints=http,https

networks:
  proxy:
    external:
      name: proxy_proxy

You need to specify both http and https as entrypoints.

@Berndinox
Copy link
Author

HY @raarts , thanks for the Update. Amazing!

@raarts
Copy link

raarts commented Feb 8, 2017

Note for keeping the downloaded certificated I used a host-mount with the local-persist driver. This means you still cannot move the treafik container around easily. Also treafik needs to run on a manager node. I prepared all my manager nodes with a /data/traefik directory

@Berndinox
Copy link
Author

Thanks for the hint!!
I'll use this with a portworx shared volume across hosts in the swarm: https://github.com/Berndinox/swarm_portworx

@emilevauge
Copy link
Member

@Berndinox @raarts if you think the documentation needs some upgrade, your help is welcome :)

@Berndinox
Copy link
Author

@emilevauge atm i do not feel confident enough to do, but may i will.. ;)

All the docu is arround the toml.conf, but i think there should be more about docker specific things:

  • how to create a traefik service in swarm
  • best practices for configuring traefik inside docker
  • real world examples (?)

BR

@raarts
Copy link

raarts commented Feb 9, 2017 via email

@Berndinox
Copy link
Author

@raarts i got one other question, would it also work if i do not persist the acme folder into a volume.
Cause when i scale the traefik service the same volume is mapped multiple times, and so i got doubled entries for my subdomains. thanks :)

@raarts
Copy link

raarts commented Feb 11, 2017

I don't think that will work. I think there are two approaches, (1) is to make sure only one container runs per host. Docker deploy does not support affinity yet, but you can claim for example cpu1 so docker will have no choice but to find another host*). (2) define two services traefik and traefik-letsencrypt, the first one is for scaling, has letsencrypt disabled, and mounts the volume read-only, and the second one has letsencrypt enabled, maybe even has proxying disabled, mounting read-write and isn't scaled.

*) Of course if you have multiple hosts, you still need one location to keep your data, so if you control the hosts, you can create a shared filesystem, using nfs or smbfs or something, and let the hosts mount those shares, the containers won't know or care. If you don't control the hosts, then I have no solution other than spending money on shared-storage-in-the-cloud somewhere, and using a volume driver.

@Berndinox
Copy link
Author

Berndinox commented Feb 12, 2017

The Read-Only approach seems to be nice! Thanks alot!

@raarts
Copy link

raarts commented Feb 12, 2017 via email

@pascalandy
Copy link
Contributor

Thanks for sharing!

@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants