What is this?
Traefik is a powerful layer 7 reverse-proxy. Once running, the proxy will give you access to 8 different webapps. I think this is a solid use-case to understand how to run this reverse-proxy.
General consideration
One of my goal here is to create the quickest demo available around the Docker ecosystem.
To accomplish this, we put together the power of:
- play-with-docker (#pwg)
- docker stacks
- docker Swarm mode
I hope the community will use this repo as a base project to demo other stuff like CMS, Log, Monitoring, storage, benchmark and other cool applications we love to use in Docker. At the very moment, Iβm trying to see if the tink stack can work for my needs.
See the demo
https://youtu.be/w3KM8yiC4d8 (90 seconds really!)
Project source
Original post on my blog > GHOST_URL/traefik-demo-docker-stack-and-play-with-docker/ and the Github repo.
Something looks weird? Please let me know
I consider this README crystal clear. If there is anything that I could improve, please let me know via an issue.
Traefik version
Find it here
Ready. Go!
- Go to http://labs.play-with-docker.com/
- Create 1 instance and wait for for the node to provision
- On node1, copy-paste:
# Create Swarm
docker swarm init --advertise-addr eth0
# List nodes
docker node ls
# Install common apps
apk update && apk upgrade && apk add nano curl bash git wget unzip ca-certificates
# Clone repo
cd /root
git clone https://github.com/pascalandy/docker-stack-this.git
cd docker-stack-this/traefik-manager
# If you prefer to use a branch...
# git checkout 1.05; sleep 1;
# Needed to mount the volume
mkdir -p /mnt/DeployGRP/tooldata/traefik/
touch /mnt/DeployGRP/tooldata/traefik/acme.json
chmod 600 /mnt/DeployGRP/tooldata/traefik/acme.json
# Launch all services
./_up
Confirm Traefik is working
-
docker service ls
is refreshing automatically for about 12 sec. -
After a while (about 20 sec) we see the logs from Traefik. Do
CTRL-C
and return to terminalβs prompt. -
Click on
8080
to see Traefik dashboard. We see all the services that run behind traefik. -
Click on
80
and at the end of the URL generate by play-with-ghost, add/who1
or/who2
or/who3
or/who4
# home, the IP is probably different in you #pwg session
http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/
http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who1
http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who2
http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who3
http://pwd10-0-7-3-80.host1.labs.play-with-docker.com/who4
Web apps details:
Why it there an error 404 when I click on 80
For this demo it's normal. It's because there is no real domain that points to the address generated by play-with-ghost. Look at the flag host - "traefik.frontend.rule=Host:mydummysite.com"
in the docker-compose named toolweb.yml
Also, in production you would point you domain name to the IP of your host.
Commands
Just execute:
./_up
./_down
./_restart
(typical flow when I debug)
This is all I got! Hope you enjoyed this!
DEV vs PROD
This is NOT prod ready
I use my own custom traefik-private.toml
(that I keep outside of this repo) and overide traefik.toml
file just after I cloned the repo. You could go fancy and do some sed' stuff as well.
Final word
Looking to kickstart you website (static page page + a CMS) ? Take a look at play-with-ghost (another project I shared). It allows you to see and edit websites made with Ghost. In short, you can try Ghost on the spot without having to sign-up!
P.S.
If you have solid skills π€ with Docker Swarm, Linux bash and the gang and yoβre looking to help a startup to launch a solid project, I would love to get to know you. Buzz me π on Twitter @askpascalandy. You can see the things that are done and the things we have to do here.
Iβm looking for bright and caring people to join this journey with me.
____ _ _ _
| _ \ __ _ ___ ___ __ _| | / \ _ __ __| |_ _
| |_) / _` / __|/ __/ _` | | / _ \ | '_ \ / _` | | | |
| __/ (_| \__ \ (_| (_| | | / ___ \| | | | (_| | |_| |
|_| \__,_|___/\___\__,_|_| /_/ \_\_| |_|\__,_|\__, |
|___/
Cheers!
Pascal
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2017 Pascal Andy
Contact: pascalandy.com @askpascalandy