Intuitive Web Hosting With Træfik

Created by Tom Purl / @tompurl

How I've always wanted to host web apps


Source: https://i.imgur.com/qt4yZVL.gif
  1. Create your DNS record (e.g. coolstuff.tompurl.com)
  2. Start your app
  3. Register your app with the reverse proxy
  4. Naturally your reverse proxy should force all traffic to use TLS

Real life


Source: https://goo.gl/GYddb5
  1. Create your DNS record (e.g. coolstuff.tompurl.com)
  2. Start your app

So far, so good!

Manually configure your reverse proxy

  • Harder than it sounds
  • Lots of esoteric gotachas with each tool
  • Very difficult to automate reliably

Manually configure your proxy to force TLS

  • Also surprisingly difficult
  • Apache and Nginx still seem to treat TLS as some sort of esoteric option

Pie in the sky with Docker

Source: https://goo.gl/oRdXx8

Docker's far from perfect, but it makes it really easy to develop, deploy and maintain complex applications

Wouldn't it be great to somehow make your reverse proxy Docker-aware?

Træfik!

Simple Config

			    
defaultEntryPoints = ["http", "https"]
[web]
address = ":8080"
  [web.auth.basic]
  users = ["tom:$apr1$.$omethingClever/"]
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
      entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]
[acme]
email = "tom@tompurl.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
onDemand = false
			    
			

Sane Defaults

  • It's easy to set up most small apps in a hurry

Hot reloading

  • To update Træfik you add special labels to your container
  • Træfik listens for newly-started containers and automatically adjusts its config

Nice extras

  • Web interface
  • Let's Encyrpt integration

Demonstration

Other cool things

  • Load balancing
  • HTTPS
  • Log export
  • Support for numerous backends

Resources

Questions?

Thank you!