I recently bought a linode virtual host and want to use it for cheap website hosting. Coming from a heroku-is-king, cattle-not-pets, saved-nothing, github-first happy-place where Procfile is your friend and /proc is a fib, I’m now so deep inside the virtualisation tesseract I can see days of the week in colours that don’t have names yet. Hold my hand, come with me. Bring a jacket, it’s Thursday.
I’m an old man now. Life was the tale of the boy who lost his server, except that nginx is running somewhere under my fingers, somewhere weird. It’s in a box, in a box, in a box; an isomorph. I no longer know what are real memories and what are –device /dev/mem.
Install CoreOS Container Linux on your linode and login
It’s cold. Your Dockerfile provides little shelter. It’s anaemic.
FROM nginx COPY ./ /usr/share/nginx/html
Static websites put the Great Hub at ease. Automated builds are tractable. Create one.
You run. You run not from fear but from exhilaration. You feel the cool wind on your face, in your hair. You own this. Or, it owns you.
linode $ docker run -it name/place
We fire and forget, use and discard, fuck and don’t call. My work is nameless and so is yours. Identity is extrinsic, one is given to us. I am not a number. My brother is a GUID, and so is my nephew.
I’m exposed. I’m on port 80; I run to see. What is “::1”? I woke up and found myself transformed into a gigantic shell. What’s happened to me? ctrl-p ctrl-q.
There’s more than one. My dentist has a website and my dog and my confessor and his. Hell is other peoples docker-compose.yaml. Here is mine. It’s yours.
version: '2' services: dentist: image: dentist/website dog: image: dog/website confessor: image: confessor/website his-confessor: image: his-confessor/website reverse-proxy: image: my/reverse-proxy links: - dentist:dentist - dog:dog - confessor:confessor - his-confessor:his-confessor
FROM nginx COPY dentist.conf /etc/nginx/conf.d/dentist.conf COPY dog.conf /etc/nginx/conf.d/dog.conf COPY confessor.conf /etc/nginx/conf.d/confessor.conf COPY his-confessor.conf /etc/nginx/conf.d/his-confessor.conf
upstream app-dog { server dog:80; } server { listen 80; server_name dog.com www.dog.com; location / { proxy_pass http://app-dog; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } }
This happens for dentist. And confessor. And his confessor.
linode $ docker-compose up -d
Ecce nova facio omnia.
Systemd, the noisome pestilence.
We can’t sit and watch, there’s other stuff to do. Tasks. systemd is there for you. Watching.
[Unit] Description=This is my church. After=docker.service Requires=docker.service [Service] TimeoutStartSec=0 ExecStartPre=/opt/bin/docker-compose -f /home/core/<master of my domain>/docker-compose.yml down ExecStart=/opt/bin/docker-compose -f /home/core/<master of my domain>/docker-compose.yml up -d ExecStop=/opt/bin/docker-compose -f /home/core/<master of my domain>/docker-compose.yml stop [Install] WantedBy=multi-user.target
Do that. His name is reverse-proxy.service. Then do this:
linode $ sudo systemctl enable reverse-proxy.service linode $ sudo systemctl start reverse-proxy.service
And then, slowly, back away. Your work is done.