Self Host 101 - Run Multiple Apps with Caddy | DNS, Static Sites, Reverse Proxies and Let's Encrypt

Syntax April 6, 2024
Video Thumbnail

About

No channel description available.

Video Description

In this video CJ shows you how to setup DNS records for domains and subdomains with Cloudflare and how to set up, configure and host multiple types of applications with Caddy Server. Watch the 1st video on setting up a VPS here: https://www.youtube.com/watch?v=Q1Y_g0wMwww Watch the 2nd video where CJ answers your questions here: https://www.youtube.com/watch?v=wZ9kmBnwX54 View all the Self Host 101 videos here: https://www.youtube.com/playlist?list=PLLnpHn493BHHAxTeLNUZEDLYc8uUwqGXa 00:00 Intro 00:56 Domain Purchase and DNS Setup 02:43 Creating DNS Records 04:32 Query DNS Records with dig 07:50 www subdomain record, CNAME records and TEXT records 10:19 Email forwarding and a catch-all address 11:23 DNS Resources 12:13 SSH to your VPS with a Domain Name 13:08 Responding to HTTP Requests from our Server 16:27 Web Server Software 18:12 Why do we need a Web Server? 19:05 How To Navigate The Caddy Docs 21:32 Caddy Architecture / reloading configuration 22:35 Install Caddy 24:17 Set up https for the root domain 25:39 Redirect IP to the root domain 27:21 Multiple Caddyfile Setup 31:41 Redirect www subdomain to root domain 34:15 Set up /var/www folder 39:05 Transfer files to the server with scp 40:35 Sync a folder with rsync 42:31 Clone a public git repo 44:44 Hide files from Caddy file_server 46:08 handle_errors in the Caddyfile 47:46 Clone private git repos with an SSH deploy key 52:16 Install node.js with nvm 54:03 Set up Holidays API Example 56:37 Create a reverse_proxy with Caddy 1:00:45 Manage long running processes with pm2 1:04:07 Run a TypeScript node.js API 1:09:52 Run a static website that has a build process 1:14:44 Caddyfile concepts and Logging 1:17:12 Common Caddyfile patterns including SPA redirects 1:18:15 Thanks! DNS on Wikipedia - https://en.wikipedia.org/wiki/Domain_Name_System Cloudflare DNS - https://www.cloudflare.com/application-services/products/dns/ dig (command) - https://en.wikipedia.org/wiki/Dig_(command) Cloudflare Email Routing - https://www.cloudflare.com/developer-platform/email-routing/ How DNS Works Zine - https://wizardzines.com/zines/dns/ Mess with DNS - https://messwithdns.net/ a simple DNS lookup tool - https://dns-lookup.jvns.ca/ netcat - https://en.wikipedia.org/wiki/Netcat Comparison of web server software - https://en.wikipedia.org/wiki/Comparison_of_web_server_software Apache HTTP - https://httpd.apache.org/ nginx - https://nginx.org/en/ traefik proxy - https://traefik.io/traefik/ Caddy Server - https://caddyserver.com/ Listen to Syntax Episode 340 - https://syntax.fm/show/340/servers-with-matt-from-caddy Caddyfile Reference - https://caddyserver.com/docs/caddyfile Caddy Architecture - https://caddyserver.com/docs/architecture Keep Caddy Running - https://caddyserver.com/docs/running#using-the-service Install Caddy - https://caddyserver.com/docs/install Caddyfile root - https://caddyserver.com/docs/caddyfile/directives/root Caddyfile file_server - https://caddyserver.com/docs/caddyfile/directives/file_server Caddyfile redir - https://caddyserver.com/docs/caddyfile/directives/redir Caddyfile Common Patterns redirect www - https://caddyserver.com/docs/caddyfile/patterns#redirect-www-subdomain ln (command) - https://en.wikipedia.org/wiki/Ln_(Unix) chown command - https://en.wikipedia.org/wiki/Chown Caddyfile file_server hide - https://caddyserver.com/docs/caddyfile/directives/file_server#hide Caddyfile handle_errors - https://caddyserver.com/docs/caddyfile/directives/handle_errors Generate an SSH key - https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent Github deploy keys - https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#deploy-keys Node Version Manager - https://github.com/nvm-sh/nvm Caddyfile reverse_proxy - https://caddyserver.com/docs/caddyfile/directives/reverse_proxy Run node.js with systemd - https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/ pm2 - https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/ Caddyfile concepts - https://caddyserver.com/docs/caddyfile/concepts How logging works in Caddy - https://caddyserver.com/docs/logging Caddyfile SPA redirect - https://caddyserver.com/docs/caddyfile/patterns#single-page-apps-spas Example sites: notlocalhost.net - https://github.com/w3cj/notlocalhost.net/ Holidays API - https://github.com/codinggarden/holidays Express API Starter TS - https://github.com/w3cj/express-api-starter-ts Big Timer - https://github.com/CodingGarden/react-big-timer ------------------------------------------------------------------------------ Hit us up on Socials! https://www.syntax.fm/links Brought to you by Sentry - Use code "tastytreats" to get 2 months free - https://sentry.io/syntax #vps #webdevelopment #selfhosted

iPhone 13 Upgrade Essentials

AI-recommended products based on this video

Loading...
VANMASS [85+LBS Strongest Suction & Clip] 2025 Upgrade Car Phone Holder [Patent & Safety Certs] Cell Phone Mount Truck Stand for Dashboard Windshield Vent for iPhone 16 Pro Max 15 14 13 12 Samsung

VANMASS [85+LBS Strongest Suction & Clip] 2025 Upgrade Car Phone Holder [Patent & Safety Certs] Cell Phone Mount Truck Stand for Dashboard Windshield Vent for iPhone 16 Pro Max 15 14 13 12 Samsung

(54,882)
$32.25
FREE delivery Mon, Aug 25 on your first order
1K+ bought in past month
Loading...
iPhone Charger Fast Charging [Apple MFi Certified] USB C to Lightning Cable 6FT USBC to Lightning Cable Nylon Braided Type C Cord for iPhone 14 13 12 11 Pro Max XR XS X 8 7 6 Plus SE, iPad

iPhone Charger Fast Charging [Apple MFi Certified] USB C to Lightning Cable 6FT USBC to Lightning Cable Nylon Braided Type C Cord for iPhone 14 13 12 11 Pro Max XR XS X 8 7 6 Plus SE, iPad

(4,036)
$8.99
FREE delivery Sun, Jun 29 on your first order
2K+ bought in past month
Loading...
iPhone Charger [Apple MFi Certified] 3FT, 3Pack USB A to Lightning Cable Braided Fast Charging Apple Cord Compatible with iPhone 14 13 12 11 Pro Max XS XR X 8 7 6 5 Plus iPad/iPod/AirPods

iPhone Charger [Apple MFi Certified] 3FT, 3Pack USB A to Lightning Cable Braided Fast Charging Apple Cord Compatible with iPhone 14 13 12 11 Pro Max XS XR X 8 7 6 5 Plus iPad/iPod/AirPods

(5,626)
$17.99
FREE delivery Sat, Jun 14 on your first order
50+ bought in past month
Loading...
2Pack 10ft iPhone Charger 90 Degree Lightning Cable Right Angle Long USB Charging Cord Compatible with Apple iPhone 14 13 12 11 Pro Max XS XR X 8 7 6 5 Plus iPad iPod

2Pack 10ft iPhone Charger 90 Degree Lightning Cable Right Angle Long USB Charging Cord Compatible with Apple iPhone 14 13 12 11 Pro Max XS XR X 8 7 6 5 Plus iPad iPod

(2,193)
$14.24
FREE delivery Sat, Jun 14 on your first order
400+ bought in past month
Loading...
for Magsafe Car Mount【20 Strong Magnets 】Magnetic Phone Holder for Car Phone Holder Mount Dash【360°】Cell Phone Mount for Car Accessories,Car Mount for iPhone 16 Pro Max 15 14 13 12 Plus MagSafe Cases

for Magsafe Car Mount【20 Strong Magnets 】Magnetic Phone Holder for Car Phone Holder Mount Dash【360°】Cell Phone Mount for Car Accessories,Car Mount for iPhone 16 Pro Max 15 14 13 12 Plus MagSafe Cases

(11,563)
$16.98
FREE delivery Tue, Jun 17 on your first order
3K+ bought in past month
Loading...
Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, Personalized Spatial Audio, Sweat- and Water-Resistant, USB-C Charging Case, H2 Chip, Up to 30 Hours of Battery Life

Apple AirPods 4 Wireless Earbuds, Bluetooth Headphones, Personalized Spatial Audio, Sweat- and Water-Resistant, USB-C Charging Case, H2 Chip, Up to 30 Hours of Battery Life

(769)
$158.99$119.24
PrimeFREE delivery Sat, Jun 14
4K+ bought in past month
Loading...
Apple AirPods Pro 2 Wireless Earbuds, Bluetooth Headphones, Active Noise Cancellation, Transparency, Personalized Spatial Audio, High-Fidelity Sound, H2 Chip, USB-C Charging

Apple AirPods Pro 2 Wireless Earbuds, Bluetooth Headphones, Active Noise Cancellation, Transparency, Personalized Spatial Audio, High-Fidelity Sound, H2 Chip, USB-C Charging

(26,678)
$259.99$194.99
FREE delivery Wed, Aug 20
5K+ bought in past month
Loading...
Wireless Charger for iPhone- 3 in 1 Charging Station for iPhone 16/15/14/13/12/Pro Max/Pro/Mini/Plus, Apple Watch 10/9/8/7/SE/6/5/4/3/2/1/Ultra2/Ultra, AirPods pro/2/3/4

Wireless Charger for iPhone- 3 in 1 Charging Station for iPhone 16/15/14/13/12/Pro Max/Pro/Mini/Plus, Apple Watch 10/9/8/7/SE/6/5/4/3/2/1/Ultra2/Ultra, AirPods pro/2/3/4

(27)
$27.99
FREE delivery Sat, Jun 14 on your first order
Loading...
3 in 1 Foldable Charging Station for Apple Wireless Charger for iPhone 16 15 14 13 12 11 Series, Wireless Charging Station with Night Light for Apple Watch Charger for AirPods 4/3/2/Pro/Pro 2 (Black)

3 in 1 Foldable Charging Station for Apple Wireless Charger for iPhone 16 15 14 13 12 11 Series, Wireless Charging Station with Night Light for Apple Watch Charger for AirPods 4/3/2/Pro/Pro 2 (Black)

(751)
$35.99$24.07
PrimeFREE delivery Sat, Jun 14
500+ bought in past month
Loading...
Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)

Anker USB C Cable, [2-Pack, 6 ft] Type C Charger Premium Nylon USB Cable, USB A to Type C Charging Cable Fast Charge for Samsung Galaxy S10 S10+ / Note 8, LG V20 and Other USB C Charger (Black)

(103,365)
$13.49
5K+ bought in past month
Loading...
2 Pack Magnetic Wireless Charger 15W Fast Mag-Safe Charger Stand Compatible with iPhone 16/15/14/13/12 Series Wireless Charging Pad for AirPods 3/2/Pro 2/Pro White Portable Mag Safe Kickstand

2 Pack Magnetic Wireless Charger 15W Fast Mag-Safe Charger Stand Compatible with iPhone 16/15/14/13/12 Series Wireless Charging Pad for AirPods 3/2/Pro 2/Pro White Portable Mag Safe Kickstand

(31)
$24.69
FREE delivery Sat, Jun 14 on your first order
500+ bought in past month
Loading...
Magnetic Wireless Charger for iPhone: Fodable 3 in 1 Charging Station for Multiple Apple Devices - Travel Charging Pad Dock for Apple Watch iPhone 16 15 14 13 12 Pro Max Plus & Airpod Global Recycled Standard

Magnetic Wireless Charger for iPhone: Fodable 3 in 1 Charging Station for Multiple Apple Devices - Travel Charging Pad Dock for Apple Watch iPhone 16 15 14 13 12 Pro Max Plus & Airpod Global Recycled Standard

(656)
$49.99
PrimeFREE delivery Sat, Jun 14
100+ bought in past month
Loading...
Wireless Earbuds, 2025 Bluetooth 5.4 Bass Stereo Headphones with 4 ENC Mic, 48H Playback Ear Buds with Charging Case LED Display,Sport Earphones IPX7 Waterproof for Phone, Android, Pad, White

Wireless Earbuds, 2025 Bluetooth 5.4 Bass Stereo Headphones with 4 ENC Mic, 48H Playback Ear Buds with Charging Case LED Display,Sport Earphones IPX7 Waterproof for Phone, Android, Pad, White

(38)
$27.99
Prime
Loading...
[ 3+3 Pack] LK 3Pack iPhone 13 Screen Protector 6.1-inch with 3Pack Camera Lens Protector, Anti-Scratch Easy-Installation,9H Hardness, HD Tempered Glass Film Global Recycled Standard

[ 3+3 Pack] LK 3Pack iPhone 13 Screen Protector 6.1-inch with 3Pack Camera Lens Protector, Anti-Scratch Easy-Installation,9H Hardness, HD Tempered Glass Film Global Recycled Standard

(62,984)
$13.49
FREE delivery Sat, Sep 20 on your first order
500+ bought in past month
Loading...
[ 3+3 Pack] LK 3Pack iPhone 13 Screen Protector 6.1-inch with 3Pack Camera Lens Protector, Anti-Scratch Easy-Installation,9H Hardness, HD Tempered Glass Film Global Recycled Standard

[ 3+3 Pack] LK 3Pack iPhone 13 Screen Protector 6.1-inch with 3Pack Camera Lens Protector, Anti-Scratch Easy-Installation,9H Hardness, HD Tempered Glass Film Global Recycled Standard

(62,984)
$13.49
FREE delivery Sat, Sep 20 on your first order
500+ bought in past month
Loading...
Magnetic Wireless Charger for iPhone - 3 in 1 Mag-Safe Charging Station for Multiple Devices Apple - Charger Stand Dock for Apple Watch iPhone 16 15 14 13 12 Pro Max Plus Airpods

Magnetic Wireless Charger for iPhone - 3 in 1 Mag-Safe Charging Station for Multiple Devices Apple - Charger Stand Dock for Apple Watch iPhone 16 15 14 13 12 Pro Max Plus Airpods

(750)
$59.99
PrimeFREE delivery Sat, Jun 14
Loading...
4-in-1 Wireless Magnetic Power Bank 10800mAh Portable Charger with iWatch Charger, QC4.0+20W PD Fast Charging USB C Battery Pack for Magsafe, iPhone 16/15/14/13/12 Series, Apple Watch etc. (White)

4-in-1 Wireless Magnetic Power Bank 10800mAh Portable Charger with iWatch Charger, QC4.0+20W PD Fast Charging USB C Battery Pack for Magsafe, iPhone 16/15/14/13/12 Series, Apple Watch etc. (White)

(581)
$42.95
PrimeFREE delivery Sat, Jun 14
Loading...
eazpower for Magsafe Power Bank 10000mAh, Magnetic Battery Pack Wireless, 20W PD Fast Charging, Compact Portable Charger with Built-in Cables and Stand for iPhone 16/15/14/13/12/ Apple Watch/Airpods

eazpower for Magsafe Power Bank 10000mAh, Magnetic Battery Pack Wireless, 20W PD Fast Charging, Compact Portable Charger with Built-in Cables and Stand for iPhone 16/15/14/13/12/ Apple Watch/Airpods

(330)
$39.99
PrimeFREE delivery Sat, Jun 14
200+ bought in past month
Loading...
Otterbox Commuter Series case for iPhone XR - Frustration Free Packaging - Black

Otterbox Commuter Series case for iPhone XR - Frustration Free Packaging - Black

(5,871)
$29.95
FREE delivery Sat, Jun 14 on your first order
50+ bought in past month
Loading...
Otterbox Commuter Series Case for iPhone 11 - Bespoke Way (blazer Blue/Stormy Seas Blue)

Otterbox Commuter Series Case for iPhone 11 - Bespoke Way (blazer Blue/Stormy Seas Blue)

(9,305)
$29.47
FREE delivery Sat, Jun 14 on your first order
200+ bought in past month