If you haven't heard there is a new hotness in automation called n8n. It reminds me of Zapier but more for developers. This isn't really to tell you how to set this up for yourself with traefik (bash script below), but per usual I like being biased and want to talk about what I thought about the whole thing.
![[n8n_project_view.png |n8n view with a workflow]]
## n8n
Overall the setup for n8n was super simple. I'm not a big biz workflow person so I wasn't sure what I would get out of this. I think I'll use it for helping with intake forms or something for apps I build. This really just looks like an excuse to make developers write workflows. I liked using Zapier UX more if we are being honest.
The biggest gripe I have here is that I can't bare-bones deploy this application. I don't really understand that. I get docker and docker compose are "the thing", but I think that for something that could grow with workflows data I want to control connections for NFS shares or external drives. I think I'm just trying to say that growing data in a docker container makes me extremely nervous over time. It's also very possible that I could have my answers if I looked in the HA documentation. I just don't need it at this time.
Lastly I wonder if there is a better way than suggesting a reverse proxy for TLS. The app works better when using TLS and not the insecure flag. I'm just spit-balling..I don't know if anyone actually cares about this stuff for real. Any way I went with Traefik so let's talk about it.
![[traefik_proof.png | traefik http view]]
## Traefik
I don't really understand the need for this honestly. I know everything deserves to have a pretty good competitor. I just feel like nginx has been solid for awhile and when we are talking about Kubernetes cluster Istio is king. Setup for Traefik wasn't super hard honestly. I think their documentation leaves some things to be desired.
I feel like I got bits and pieces of things but not the whole picture to get TLS to work with let's encrypt. With the help of ChatGPT I was about to fix the `traefik.yaml` file to get things working. I also got some ideas to make things a little better with docker network and such.
I've never done a nginx reverse proxy (that I have documented), so I don't know if it would have been easier. n8n seems to prefer Traefik so I figured I'd give it a try. My biggest gripe ended up being that I seemingly can't get to the dashboard without a setting things to insecure. Why would you do that? I get that this service allows things to look like the server doesn't have all this going on under the hood, but nothing wrong with letting people lock down a port for an admin panel.
---
As promised here is a bash script for ubuntu that you can use to help set things up. **NOTE: I didn't include traefik.yaml**
```sh
#!/bin/bash
echo "Start of userdata script..."
sudo apt update
# Docker install
echo "Installing docker..."
sudo apt-get install ca-certificates curl -y
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
sleep 1m
# Add local user to docker group
echo "Add user to docker..."
sudo usermod -aG docker $USER
# Install traefik
docker network create traefik
touch acme.json
chmod 600 acme.json
docker run -d --rm --name traefik -p 443:443 -p 80:80 \
--network traefik \
-v $PWD/traefik.yaml:/etc/traefik/traefik.yaml \
-v $PWD/acme.json:/acme.json \
-v /var/run/docker.sock:/var/run/docker.sock \
traefik:v3.4
# Install n8n
echo "Installing n8n..."
docker volume create n8n_data
# Replace the domain with your domain
docker run -d --rm --name n8n -v n8n_data:/home/node/.n8n \
--network traefik \
-l traefik.enable=true \
-l traefik.http.routers.n8n.rule=Host\(\`domain.com\`\) \
-l traefik.http.routers.n8n.entrypoints=websecure \
-l traefik.http.routers.n8n.tls.certresolver=myresolver \
-l traefik.http.services.n8n.loadbalancer.server.port=5678 \
docker.n8n.io/n8nio/n8n
```