Quick start to HTTPS with Caddy

Caddy is a easy-to-use web server and reverse proxy. You can use it to enable HTTPS on your self-hosted app with little effort.

To start off, first download caddy for your platform. Place the executable in a nice folder. We'll call that your working directory.

Now in the same folder, you will need to write a Caddyfile, which is just a text file. Open your text editor and paste this:

:2015 {
    proxy / localhost:8080
}

Save it as Caddyfile without any file extension.

This will start a normal HTTP server at port 2015 and proxy all requests to your app at port 8080.

Now, in the terminal or command prompt, cd into the working directory and run Caddy. On Windows you would type caddy.exe and on macOS or Linux ./caddy

You can now visit localhost:2015 to check that everything works.

Next, you have to get a domain to point to your server. You can get free domains from freenom.tk, or use your dynamic DNS provider. You can test that your domain works by visiting your-domain.com:2015 over mobile data or from a different network.

After that, enabling HTTPS is really simple. Open your Caddyfile and modify it to look like this:

your-domain.com {  
    proxy / localhost:8080
}

Save the file and restart Caddy. You may have to run Caddy as root (with sudo) or in an administrator command prompt. Caddy will ask for your email on the first time you run it, and then it will automatically verify that you own the domain, generate and sign a HTTPS certificate for you! Caddy makes it so convenient to set up HTTPS.

You can now visit https://your-domain.com!