Lección 2 · Módulo 3: Your AI Operating System on a Private Server
Renting a VPS and securing it: domain, SSL and firewall basics
- Rent a VPS and log in safely with SSH keys
- Point your own domain at it with DNS
- Lock it down with a firewall and free SSL
Why this matters
Maya's automation stopped working the moment her laptop went to sleep, and twelve customers waited all weekend for replies. An automation that talks to customers has to run on a machine that stays on, and it needs an address and a secure entry point that customers can safely use. This lesson shows how to rent that machine, give it a memorable name, and lock it down before anything valuable runs on it.
Key ideas
- A VPS is your own always-on slice of a server. A hosting company runs large physical computers and splits each one into many virtual machines. You rent one of those slices, get your own memory, storage and processor, and it stays on whether your laptop is open or not.
- A DNS A record turns a name into a number. Your server has an IP address such as 203.0.113.10, which is hard to remember. An A record tells the internet's phone book that a name like bookings.yourshop.com points to that address. Example:
bookings.yourshop.com→203.0.113.10.
- SSH keys replace passwords. A key pair works like a lock and its only key. The public half goes on the server, the private half stays on your laptop. Once password login is switched off, guessing bots have nothing to try.
- A firewall opens only the doors you name. Each service listens on a numbered port. The firewall denies everything by default, then opens only SSH (for you), port 80 (plain web) and port 443 (encrypted web).
- Caddy adds free, self-renewing SSL. Caddy fetches certificates from Let's Encrypt, which proves your site is genuine and turns on the padlock. It also acts as a reverse proxy: it receives public visitors and passes them to the app running privately inside the server.
Try it before you watch
Your shop's booking page is on a server at 203.0.113.10. A customer types bookings.yourshop.com. Which record does the internet's phone book need, and what must its value be?
Show answerHide answer
An A record named bookings whose value is 203.0.113.10, so the name resolves to the server's IP address. This shows how a name becomes a number the browser can connect to.
Words to know
- VPS: a virtual private server, a slice of a big computer that you rent and control as if it were your own machine.
- SSH: secure shell, a protected text connection that lets you control a server from your laptop.
- Port: a numbered door on a server; each service listens at its own port, such as 443 for HTTPS.
- DNS: the domain name system, the internet's phone book that converts names into IP addresses.
- Reverse proxy: a front-desk program that receives visitors and forwards each request to the right app behind it.
- SSL / TLS: the encryption that scrambles traffic between a visitor and your server, shown as a padlock in the browser.
What to watch for
- Notice which command runs on your laptop and which runs on the server; the on-screen comments show the difference, and mixing them up is a common beginner slip.
- Watch how the firewall lines deny everything first and then open only three doors, and why that order matters.
- Pay attention to the Docker warning: a port published without the 127.0.0.1 prefix can bypass the firewall and expose your database to the whole internet.
Apréndelo con tu tutor en la pizarra en vivo
Puntos clave del video
The weekend the laptop slept
- Maya runs a small online yoga studio
- Her lead-booking automation ran on her laptop
- Laptop closed for the weekend: 12 messages unanswered
- Fix: a small server that never sleeps
layout: wide
direction: LR
components:
customer: {kind: user, label: Customers}
form: {kind: client, label: Trial form}
laptop: {kind: service, label: Maya's laptop}
inbox: {kind: queue, label: Messages}
links: [customer->form, form->laptop, form->inbox]
steps:
- at: "Picture Maya"
show: [laptop]
note: "Maya runs the studio"
- at: "built an automation on her laptop"
show: [laptop]
highlight: [laptop]
note: "Built on her laptop"
- at: "A form answer comes in"
show: [laptop, customer, form]
flow: ["customer>form: form answer", "form>laptop: qualify lead"]
- at: "until she closed the laptop"
show: [laptop, customer, form]
highlight: [laptop]
note: "Laptop closed"
- at: "twelve customer messages were waiting"
show: all
highlight: [inbox]
flow: ["form>inbox: 12 messages"]
note: "12 unanswered"
- at: "has to be awake"
show: all
highlight: [laptop]
note: "Needs to stay awake"
- at: "a proper web address"
show: all
highlight: [form]
note: "A proper web address"
- at: "renting a small server that never sleeps"
show: all
highlight: none
note: "A server that never sleeps" What you will learn
- Rent a VPS and log in safely with SSH keys
- Point your own domain at it with DNS
- Lock it down with a firewall and free SSL
layout: side
direction: right
tree:
Your server:
Rent a VPS: [Key login]
Point a domain: [Domain name]
Lock it down: [Firewall, Free SSL]
steps:
- at: "three things"
grow: Your server
note: "Three things to build"
- at: "rent a virtual private server"
highlight: Rent a VPS
- at: "using a key instead of a password"
grow: Rent a VPS
highlight: Key login
- at: "point a domain name you own"
grow: Point a domain
highlight: Point a domain
- at: "a string of numbers"
note: "Not a string of numbers"
- at: "lock it down with a firewall"
grow: Lock it down
highlight: Lock it down
- at: "the padlock in the browser"
highlight: Free SSL
note: "SSL: the browser padlock"
- at: "a server, a name and a lock"
highlight: [Rent a VPS, Point a domain, Lock it down]
- at: "every later lesson"
highlight: none
- at: "builds on these three"
note: "Later lessons build on these three" What a VPS really is
- VPS = virtual private server
- Your own slice of memory, storage and processor
- Shared hosting gives you only a folder
layout: wide
direction: LR
components:
building: {kind: cloud, label: Data centre}
flat: {kind: container, label: Your VPS}
key: {kind: user, label: You, icon: key-round}
shared: {kind: file, label: Shared folder}
links: [building->flat, key->flat]
steps:
- at: "A hosting company owns huge physical computers"
show: [building]
highlight: [building]
note: "Huge physical computers"
- at: "each one is split into many virtual machines"
show: all
highlight: [building]
note: "Split into many virtual machines"
- at: "A VPS, short for virtual private server"
show: [building, flat]
highlight: [flat]
note: "VPS: virtual private server"
- at: "your own slice of memory, storage and processor"
show: [building, flat]
highlight: [flat]
note: "Your own slice"
- at: "You alone hold the way in"
show: [flat, key]
flow: ["key>flat: your key"]
highlight: [key]
note: "You hold the key"
- at: "shared hosting, where you only get a folder"
show: [shared]
highlight: [shared]
note: "Shared hosting: only a folder"
- at: "the whole flat is yours to furnish"
show: all
highlight: [flat]
note: "The whole flat is yours" Choosing a plan
- Start: 2 vCPU, 4 GB RAM, 80 GB SSD
- Operating system: Ubuntu 24.04 LTS
- Pick a region close to your customers
- Providers: Hetzner, DigitalOcean, Hostinger
layout: side
direction: down
start: none
tree:
Your VPS: [vCPU, RAM, SSD, "Ubuntu 24.04 LTS", Region, Hetzner, DigitalOcean, Hostinger]
steps:
- at: "Which size of VPS"
show: "Your VPS"
- at: "A vCPU is a share"
show: vCPU
- at: "RAM is short-term memory"
show: RAM
- at: "SSD is the storage drawer"
show: SSD
- at: "a comfortable start"
highlight: [vCPU, RAM, SSD]
- at: "Choose Ubuntu"
show: "Ubuntu 24.04 LTS"
- at: "Pick a region"
show: Region
- at: "Hetzner"
show: Hetzner
- at: "DigitalOcean"
show: DigitalOcean
- at: "Hostinger"
show: Hostinger
- at: "resize later"
highlight: "Your VPS"
note: "Resize later, in a couple of clicks" Giving the server a name with DNS
- Your server has an IP address: 203.0.113.10
- DNS is the internet's phone book
- Add an A record: bookings points to the IP
- Changes spread in minutes, sometimes hours
layout: full
parts:
vps: {chip: Your VPS, sub: "Answers the visit", icon: server}
dns: {chip: DNS, sub: "The phone book", icon: book-open}
customer: {chip: Customer, sub: "Types the address", icon: user}
net: {box: Internet, holds: [vps, dns, customer]}
ask: {chat: "bookings.yourshop.com"}
steps:
- at: "Your new server comes with an IP address"
spokes: {of: vps, items: [IP address, 203.0.113.10]}
- at: "DNS, the domain name system"
spokes: {of: dns, items: [Names to numbers, Phone book]}
- at: "you add an A record"
spokes: {of: dns, items: ["A record: bookings", "Value: the IP"]}
- at: "a customer types bookings dot your shop dot com"
highlight: customer
send: ask
- at: "their browser looks up the phone book"
highlight: dns
- at: "lands on your VPS"
highlight: vps
- at: "New records usually spread within minutes"
note: "Minutes, sometimes hours" First login with SSH keys
# 1. on your laptop: make the key pair
ssh-keygen -t ed25519
# 2. log in as root, then on the server
ssh [email protected]
adduser maya
usermod -aG sudo maya
exit
# 3. back on your laptop
ssh-copy-id [email protected]
ssh [email protected] Closing the password door
- Keys only help once passwords are switched off
- Keep this session open while you test
# on the server, as maya
echo "PasswordAuthentication no" | sudo tee /etc/ssh/sshd_config.d/00-lockdown.conf
echo "PermitRootLogin no" | sudo tee -a /etc/ssh/sshd_config.d/00-lockdown.conf
sudo systemctl restart ssh The firewall: one door per job
sudo ufw default deny incoming
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable SSL in three lines with Caddy
- SSL, or TLS, encrypts all traffic: the padlock
- Certificate: an ID card that proves who you are
- Caddy fetches free Let's Encrypt certificates
- Reverse proxy: public door → app inside
bookings.yourshop.com {
reverse_proxy localhost:5678
} Worked example: one lead, end to end
- A visitor fills Maya's trial-class form
- Every hop is named, locked and filtered
layout: wide
direction: LR
components:
user: {kind: user, label: Customer}
dns: {kind: cloud, label: DNS}
fw: {kind: gateway, label: Firewall, icon: shield}
caddy: {kind: loadbalancer, label: Caddy}
n8n: {kind: service, label: n8n}
db: {kind: database, label: Postgres}
zones:
- {label: Your VPS, contains: [fw, caddy, n8n, db]}
links: [user->dns, user->fw, fw->caddy, caddy->n8n, n8n->db]
steps:
- at: "Let's follow one real lead"
show: [user]
- at: "a visitor on her phone"
highlight: [user]
- at: "the DNS phone book"
show: [user, dns]
highlight: [dns]
- at: "everything inside the VPS"
show: all
- at: "stores the leads"
highlight: [db]
- at: "She presses the submit button"
highlight: [user]
- at: "asks DNS for the address"
flow: ["user>dns: lookup", "dns>user: 203.0.113.10"]
- at: "arrives encrypted on port 443"
flow: ["user>fw: HTTPS 443"]
- at: "the firewall lets it through"
flow: ["fw>caddy"]
- at: "hands it to n8n"
flow: ["caddy>n8n: webhook"]
- at: "n8n listens on"
highlight: [n8n]
note: "Webhook: a listening address"
- at: "saves the lead in the database"
flow: ["n8n>db: save lead", "db>n8n"]
- at: "travels back the same way"
flow: ["n8n>caddy", "caddy>fw", "fw>user: 200 OK"]
- at: "Every hop was named"
show: all
highlight: none
note: "Named, locked and filtered" Common mistake: Docker skips your doorman
- Docker publishing a port can bypass UFW rules
- Database on 5432 open to the whole internet
- Fix: bind ports to 127.0.0.1 only
- Let only Caddy face the outside world
ports:
- "127.0.0.1:5432:5432" Recap
- A VPS is your own always-on slice
- DNS A record gives it a name; SSH keys guard the login
- Firewall plus Caddy: three open doors, free SSL
layout: side
objects:
title: {text: "Recap", pos: top}
vps: {text: "VPS: always on", pos: top_left, color: accent}
dns: {text: "DNS A record: a name", pos: top_right, color: chalk}
ssh: {text: "SSH keys: only you", pos: bottom_left, color: green}
wall: {text: "Firewall: doors shut", pos: center, color: orange}
doors: {tex: '1 + 1 + 1 = 3 doors open', pos: bottom}
caddy: {text: "Caddy: free SSL padlock", pos: bottom_right, color: purple}
ready: {text: "Ready for the real work", pos: center, color: green}
bookings: {text: "Booking confirmations, day and night", pos: bottom, color: green}
steps:
- at: "pull it together"
show: title
- at: "always-on slice"
show: vps
- at: "turns its number"
show: dns
- at: "SSH keys"
show: ssh
- at: "a firewall keeps every door shut"
show: wall
- at: "except SSH"
hide: wall
show: doors
- at: "Caddy adds free, self-renewing SSL"
show: caddy
- at: "passes visitors to the right app"
highlight: caddy
- at: "ready for the real work"
hide: doors
show: ready
- at: "booking confirmations can flow"
hide: ready
show: bookings Your exercise
- Rent the smallest VPS that fits: 2 vCPU, 4 GB
- Create a user, add your SSH key, turn off passwords
- Enable UFW and point a subdomain at it
- Install Caddy (caddyserver.com), use respond "Hello"
layout: side
direction: down
start: none
tree:
Your exercise: [Rent a VPS, Keys and login, Firewall, DNS A record, Caddy]
steps:
- at: "rent the smallest VPS"
show: ["Your exercise", "Rent a VPS"]
- at: "Make your key pair"
show: "Keys and login"
- at: "switch on UFW"
show: "Firewall"
- at: "Add an A record"
show: "DNS A record"
- at: "install Caddy"
show: "Caddy"
- at: "Open that address"
highlight: "Caddy"
- at: "see the padlock"
highlight: "Caddy"
note: "Padlock means done"
- at: "Keep the IP address"
highlight: none
note: "Next: install n8n" Transcripción
The weekend the laptop slept. Picture Maya. She runs a small online yoga studio, and last month she built an automation on her laptop. A form answer comes in, an agent qualifies the lead, then books a trial class. It worked beautifully until she closed the laptop for the weekend. By Monday, twelve customer messages were waiting with no reply. An automation that answers customers has to be awake when they are, and it needs a proper web address that's safe to share. That's today's job: renting a small server that never sleeps, giving it a name, and locking its doors.
What you will learn. By the end of this lesson you'll be able to do three things. First, rent a virtual private server and log in to it safely using a key instead of a password. Second, point a domain name you own at that server, so customers reach bookings dot your shop dot com instead of a string of numbers. Third, lock it down with a firewall and free SSL, the padlock in the browser. Think of it as a server, a name and a lock. Every later lesson in this module builds on these three.
What a VPS really is. So what are you actually renting? Start with the building. A hosting company owns huge physical computers in a data centre, and each one is split into many virtual machines. Now look at your flat. A VPS, short for virtual private server, is one of those flats: your own slice of memory, storage and processor, with your own operating system, and no neighbours walking through. And here's the key. You alone hold the way in, and you decide what runs inside. That's very different from shared hosting, where you only get a folder. With a VPS, the whole flat is yours to furnish.
Choosing a plan. Which size of VPS do you need? A vCPU is a share of the processor, the part that does the work. RAM is short-term memory, like the size of your desk: more room means more tools open at once. SSD is the storage drawer. For n8n, a database and a few agents calling cloud AI models, two vCPUs, four gigabytes of RAM and eighty gigabytes of SSD is a comfortable start. Choose Ubuntu 24.04 LTS as the operating system, where LTS means long-term support, so security fixes keep coming for years. Pick a region close to your customers, because a closer server means faster replies. Hetzner is one choice. DigitalOcean is another. Hostinger is a third, and any of them works for this course. Don't overthink it: most providers let you resize later in a couple of clicks.
Giving the server a name with DNS. Your new server comes with an IP address, a number like 203 dot 0 dot 113 dot 10. It works, but nobody will remember it, and you can't put it on a business card. DNS, the domain name system, is the internet's phone book: it turns names into numbers. At the company where you bought your domain, you add an A record. Its name is bookings, and its value is your server's IP address. Now when a customer types bookings dot your shop dot com, their browser looks up the phone book and lands on your VPS. New records usually spread within minutes, though sometimes it takes a few hours.
First login with SSH keys. SSH, or secure shell, is a protected text connection from your laptop to the server. Watch the comment lines on screen: they tell you where each command runs. First, on your laptop, ssh-keygen makes a key pair. A key pair works like a lock and its only key: the public key is the lock you hand to the server, and the private key never leaves your laptop. Next, log in as root, the all-powerful admin. Let's slow down here. On the server, create an everyday user called maya and add her to the sudo group, which lets her borrow admin powers only when she asks. Type exit to come back to your laptop. There, ssh-copy-id asks for maya's password one last time and copies your public key to the server. Log in again, and no password is asked. After this, you never type a password to log in.
Closing the password door. A key only protects you once the old password door is shut. Still logged in as maya, these two lines write a small settings file for SSH: one turns off password login, the other stops root from logging in at all. It does the same job as editing the main settings file, sshd_config, but Ubuntu reads this small file first, so a setting left by your provider can't switch passwords back on. Then we restart SSH. Before you close anything, keep this window open and try a fresh login from a second window. If that new login fails, the open session is your way back in to fix it. Once it works, the bots that guess passwords have nothing left to guess.
The firewall: one door per job. A port is a numbered door on the server, and each service listens at its own door. A firewall is the doorman who decides which doors open at all. UFW, the uncomplicated firewall on Ubuntu, makes this easy. First we deny every incoming door by default. Then we open exactly three: SSH so you can log in, port 80 for plain web traffic, and port 443 for HTTPS, the encrypted web. Finally we switch it on. That's it. Thousands of automated bots scan every new server within hours, and now they find almost every door shut.
SSL in three lines with Caddy. SSL, now officially called TLS, encrypts all traffic between the customer and your server, which is why the padlock shows in the browser. To do that, your server needs a certificate, a digital ID card that proves who you are, so visitors know it really is bookings dot your shop dot com. Here's the shortcut: Caddy, a small web server, fetches free certificates from Let's Encrypt and renews them by itself. To install it, follow the steps for Ubuntu on caddyserver dot com. Those three lines are the whole setup. Caddy acts as a reverse proxy, the receptionist at the front desk, passing each visitor to the room where n8n actually lives, on port 5678. n8n arrives in the next lesson, so until then, put respond Hello in place of the reverse proxy line and Caddy will show a simple page.
Worked example: one lead, end to end. Let's follow one real lead. Start with a visitor on her phone who wants a trial yoga class, plus the DNS phone book she'll ask first. Now look at everything inside the VPS: the firewall, Caddy, n8n and Postgres, the database that stores the leads. She presses the submit button. Her phone asks DNS for the address and gets the IP back. The request arrives encrypted on port 443, the firewall lets it through, and Caddy hands it to n8n through a webhook, an address n8n listens on for incoming form data. n8n saves the lead in the database, and the confirmation travels back the same way. Every hop was named, locked and filtered.
Common mistake: Docker skips your doorman. Here's the trap that catches experienced people. In the next lesson you'll install apps with Docker, and when Docker publishes a port, it writes its own network rules that can slip past UFW entirely. Your doorman guards the front, but the side window is wide open, and suddenly your customer database on port 5432 is reachable by anyone. The fix is simple. Publish internal ports on 127 dot 0 dot 0 dot 1, which means this machine only. In the ports line on screen, that address comes first, then the port twice: 127 dot 0 dot 0 dot 1, colon 5432, colon 5432. Then let only Caddy face the outside world, and everything else sits safely behind it.
Recap. Let's pull it together. A VPS is your own always-on slice of a big computer, so Maya's automations keep answering while she sleeps. A DNS A record turns its number into a name customers can trust, and SSH keys, with password and root login switched off, mean only your laptop can log in. Finally, a firewall keeps every door shut except SSH, 80 and 443, while Caddy adds free, self-renewing SSL and passes visitors to the right app. With those pieces in place, your server is ready for the real work, and the booking confirmations can flow day and night.
Your exercise. Now it's your turn. Before the next lesson, rent the smallest VPS that fits our plan, two vCPUs and four gigabytes of RAM. Make your key pair, create your own user, copy your SSH key across, and switch off password and root login. Then switch on UFW with only SSH, 80 and 443 open. Add an A record for a subdomain, something like automations dot your business dot com, pointing at the server. Finally, install Caddy using the steps on caddyserver dot com, and in your Caddyfile write respond Hello instead of the reverse proxy line. Open that address in your browser. When you see the padlock, you're done. Keep the IP address and login handy, because next time we install n8n.
Explora las animaciones
Las animaciones del video, exactas y en vivo: reprodúcelas, pausa, arrastra el control deslizante o salta a un paso a tu propio ritmo.
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Responde todas las preguntas y luego comprueba. Apruebas con 70%; puedes intentarlo las veces que quieras.
Resumen de la lección
- Lectura
- Video visto
- Cuestionario aprobado (70%)
- A VPS is your own always-on slice
- DNS A record gives it a name; SSH keys guard the login
- Firewall plus Caddy: three open doors, free SSL