j

m

o

o

r

e

.

d

e

v

Links

Migration in progress

This article is still being migrated to the new site, please view the old version for now.

Install & Configure Caddy as an Express.js reverse proxy

Preamble

I didn't like how Caddy's official Getting Started guide was written, so I made my own guide that I feel is much easier to follow.


This guide will configure Caddy to:

  • automatically register & renew HTTPS certificates for your domain
  • redirect HTTP requests to HTTPS
  • redirect www. to non-www.

Requirements

  • A Debian/Ubuntu-based Linux server
  • An existing Express.js app
  • root command line access (and a basic understanding of using a terminal)
  • A domain name with A and AAAA records pointing towards your server

Step 1 - Remove or disable existing webservers

If you want to remove any existing webservers, run the following command:

sudo apt remove apache2 nginx nginx-common lighttpd

This will remove Apache, Nginx, and lighttpd.


If you just want to disable these, run these commands:

sudo systemctl stop apache2 nginx lighttpd
sudo systemctl disable apache2 nginx lighttpd

This will stop any running webservers and disable them from running on startup.