sinpro.dev
Docs
Team sinProject
Docs History
  • Company Information
    • Portfolio
    • About
    • Services
    • Events
  • Dev Environment
    • macOS Settings
    • Chrome Extensions
    • VSCode Workspace Settings
    • VSCode Workspace Extensions
    • Global NPM Packages
    • npm-check-updates
    • SvelteKit
    • Customize Zsh
    • ChatGPT Prompts
    • Tailwind CSS
    • Warp
    • Keyboard Shortcuts
  • Assets
    • Assets
    • JPG/PNG to AVIF
    • TTF to WOFF2
  • Clean Code
    • Clean Code
    • Format
    • Quality
    • Variables
    • Functions
    • Objects and Data Structures
    • Classes
    • Concurrency
    • Error handling
    • Comments
  • Code Style
    • TypeScript Config
    • Prettier
    • ESLint
    • Stylelint
  • Testing
    • Vitest
    • Playwright
  • Git
    • Git Branches and Commits
    • Git Hooks
    • Git User Profiles
    • Git for Windows
  • GitHub
    • GitHub Issues
    • GitHub Pull Requests
    • GitHub Repository Settings
    • GitHub Branch Protection
    • GitHub Actions
  • Code Quality
    • SonarCloud Coverage
  • Server
    • SSH
    • PM2
    • Caddy
    • Updating the server
    • ngrok
  • Team sinProject
    • Our Team Policy
    • Equipment and Supplies
    • Books
    • Slack
    • Locales
    • Funny Apps
    • Docs History
  • Talk
    • Talk
    • Creating a Project
    • App Structure

Server

Caddy

Edit this page

Caddy is an open-source, HTTP/2-enabled web server. It’s notable for its easy configuration, automatic HTTPS, and capability to serve static sites or reverse proxy.

Caddy Quick Start >

Installation

Get Caddy on Ubuntu:

Bash
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Starting Caddy Service

Check if Caddy service is running:

Bash
sudo systemctl status caddy

If it’s not running, start it:

Bash
sudo systemctl enable --now caddy

Enabling the service will start Caddy automatically when the server boots up.

Caddy Configuration

Edit the Caddyfile:

Bash
sudo micro /etc/caddy/Caddyfile

Add your site configurations:

.server/etc/caddy/Caddyfile
sinpro.dev {
	reverse_proxy :3001
}

talk.sinpro.dev {
	reverse_proxy :3002
}

Add cache control:

.server/etc/caddy/Caddyfile
sinpro.dev {
	reverse_proxy :3001

	@static path *.avif *.woff2 *.png
	header @static Cache-Control "public, max-age=86400, must-revalidate"
}

Finally, restart the Caddy service to apply the changes:

Bash
sudo systemctl restart caddy

More info >

PM2 Updating the server
© sinProject. v0.73.0
On this page
  • Caddy
  • Installation
  • Starting Caddy Service
  • Caddy Configuration