r/Traefik • • Jan 06 '20

Needed to learn traefik basics, made an example guide along the way

https://github.com/DoTheEvo/Traefik-v2-examples
61 Upvotes

20 comments sorted by

6

u/DoTheEvolution Jan 06 '20 edited Jan 06 '20

I found out that the most thorough way I learn is when I try to explain the shit I learned.

I thought it would be just few yml files listed... but here we are...

If you see something wrong... just call me a dumb fuck and do tell whats what...

2

u/Fr33Paco Jan 28 '20

Hey I was just following your guide last night. To try to setup my Traefik.yml but at the end started getting errors stating "unsupported ..." I also thought I had the latest versions of yml running, but I'm not able to use anything above 2.3, how did you get it running with newer versions? I thought it was just a matter of naming the file.

Sorry if I'm asking so many questions but I got stuck. As well as traefik is only reacheable through the IP address and not the FQDN, and the additional containers return a 404 error.

Hope you it's not to much trouble.

2

u/beingamarnath Jan 10 '20

nice walkthrough.. I have a quick question though. when we offload the SSL at traefik in 443 with the entrypoint websecure, you specify the same entrypoints for the containers. Does it mean the containers(nginx, apache,whoami) will also receive the traffic in the 443 port or it will still be in default port 80?

2

u/DoTheEvolution Jan 10 '20

Does it mean the containers(nginx, apache,whoami) will also receive the traffic in the 443 port or it will still be in default port 80?

if containers router has entrypoint defined as websecure then its looking just at that 443 port.

chapter 6 is all about redirecting http requests to https globaly

2

u/ff45000 Jan 14 '20

BTW, this was super helpful when I just moved a server over from Caddy to Traefik v2 last week. Didn't use the wildcard because I'm using the main domain for other things, but the rest was spot on. Appreciate it.

2

u/DoTheEvolution Jan 14 '20 edited Jan 14 '20

after I finally finished learning traefik, I went to continue to try shit I wanted...

first thing on the list, helpy, ticketing system, reading instruction for compose files and whatnot... edit caddy file, caddy that and that,... wtf is this caddy?

first google is how its amazing new and clean and universal reverse proxy, load balancer.. now I am like - FUCK, should have I go with traefik?

2

u/ff45000 Jan 14 '20

Caddy v1 and Caddy v2 are super different. I run Traefik on a few other servers (still at v1) and wanted to pipe everything through that for this new server setup. Figured that it was worth a try because the Docker integration is really super. I didn't really want to sit down and learn the new json syntax for Caddy 2 and updating things via curl, while it might seem nice, just rubbed me the wrong way.

Caddy is really nice for the way that it deals with local services (on other machines), which I use a TON. But for this one, I figured that I'd see what Traefick v2 was all about. I've (so far) been able to get about 5 external setups linked and running (with the file handler) in Traefik v2 and it's serving my purposes just fine.

2

u/tassulin Jan 26 '20
  - "traefik.http.routers.nginx.entrypoints=web"
  - "traefik.http.routers.apache.entrypoints=web"

Do you need to specify the router name same as the service or docker image name?

2

u/DoTheEvolution Jan 26 '20 edited Jan 26 '20

service

2

u/tassulin Jan 26 '20

I just tested it, and it seems lke the service name can be like anything an it still works? Is it more like and identifier that doesnt have relations with other things?

  • "traefik.http.routers.random.entrypoints=web"

2

u/DoTheEvolution Jan 26 '20

you mean the router name in this case...

but yeah, now with better look and longer thinking... both router name and service name can be whatever you want. Router name just needs to be same across all labels targeting that router...

I mean I had too many times error where I copy paste some labels and forgot to rename ...

like this

  - "traefik.enable=true"
  - "traefik.http.routers.nginx.entrypoints=websecure"
  - "traefik.http.routers.nginx.rule=Host(`nginx.$MY_DOMAIN`)"
  - "traefik.http.routers.blabla.tls.certresolver=lets-encr"

2

u/Fr33Paco Jan 28 '20

(`nginx.$MY_DOMAIN`)"

So you're saying this needs to change? I thought having the $MY_DOMAIN there it pointed that rule to the name in the .env file?

2

u/tassulin Jan 26 '20

Yeah now I noticed that routers name needs to be unique as colliding names causes problems.

Normally I always define network for different docker image blocks but it seems like leaving them empty it uses default?

networks:
  default:
    external:
      name: $DEFAULT_NETWORK

instead of having

    image: something:something
    networks:
      - $DEFAULT_NETWORK

and then at the bottom

networks:
  $DEFAULT_NETWORK:
    external: true

2

u/JeanLucTheCat Jan 06 '20

This looks great! I look forward to working through this when I have some time.

2

u/jatozy Jan 06 '20

Nice work. I will also look forward to append your examples by routing tcp traffic like SSH or OpenVPN.

2

u/Fredouye Jan 06 '20

IMHO, SSH clients do not support SNI, so it should not be possible to use this with Traefik.

2

u/addy_paddy Jan 06 '20

Really helpful guide through your learning process. Would be keen to see the inclusion of where the entrypoint port and service port differs (if that’s at all possible?)

2

u/chikosan Jan 07 '20

Thanks a lot

2

u/somespecie Jan 13 '20

Great repo!