Installing Caprover - Self Hosted deployment & web server manager

· 3 min read

CapRover is an extremely easy to use app/database deployment & web server manager. It is a FOSS alternative to Cloudron. Similar products include YunoHost and Yatch. It’s blazingly fast and very robust as it uses Docker, nginx, Lets Encrypt and NetData under the hood behind its simple-to-use interface.

There are several ways of deploying caprover. From their website, the recommended way of deploying it is using their one click app available on digital ocean. You can use the following link to sign up for a 60-Day 200 dollar credit.

DigitalOcean Referral Badge

However, in this tutorial I will demonstrate how to install caprover on any server, regardless of whether it is a VPS on a different cloud or a home server in your home lab.

Prerequisites

Before deploying caprover, you will need to have at least the following:

  1. Domain Name — you can get domains as cheap as $1 on any domain name provider. My preference is Namecheap
  2. Server — this is of course where the application will sit, preferable one with a public IP. You can however choose to install CapRover locally on your laptop on a private network which is behind NAT (your router). But if you want to enable HTTPS and/or access the apps from outside your private network, it requires some special setup, like port forwarding. Be sure to follow their documentation to achieve this

Server specs

Any CPU Architecture and docker. However, it is recommended to use Ubuntu 20.04 and docker version 19.03.

A recommended RAM of at least 1GB is suitable to make sure the build process runs successfully.

Install docker using the official installation instructions. Avoid using snaps.

Make sure the required ports are opened/allowed on your firewall or security groups on whichever cloud provider you are using.

ufw allow 80,443,3000,996,7946,4789,2377/tcp; 
ufw allow 7946,4789,2377/udp;

CapRover Installation

Step 1: Installation

Installing caprover is as simple as running the following command:

docker run -p 80:80 -p 443:443 -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock -v /captain:/captain caprover/caprover

NOTE: Do not change the specified ports, as caprover only works on specific ports.

Once the CapRover is initialized, you can visit http://[IP_OF_YOUR_SERVER]:3000 in your browser and login to CapRover using the default password captain42. You can change your password later. However, do not make any changes in the dashboard. You’ll use the command line tool to set up the server.

Step 2: Connect Root Domain

Add an A record to your domain registrar that maps a wildcard subdomain (*.something.com) to the IP address of your CapRover server.

Steps:

  1. Access your domain registrar’s DNS config.
  2. Create an A record:
  • HOST: *.something
  • POINTS TO: IP of CapRover server
  • TTL: ~1 hour

sample caprover Cloudflare DNS configuration

Notes:

  • DNS changes can take up to 24 hours to propagate.
  • A TTL of ~1 hour is recommended.
  • CapRover requires A Record to be pointing to CapRover’s IP Address. If you use proxy services, such as Cloudflare, you may face difficulties. CapRover does not officially support such use cases.

Step 3: Install CapRover CLI

The caprover CLI runs on NPM. The recommended way of installing NPM is via a package manage. There is a detailed guide on how to install Node.js $ NPM on the GitHub page.

For instance, if you are using the recommended Ubuntu version, 20.o4, run the following command to install Node.js 18.x LTS. It is recommended to use the LTS version.

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\sudo apt-get install -y nodejs

Once NPM is installed, simply run npm install -g caprover to install the caprover CLI. Then, run caprover serversetup to begin the server setup.

Step 4: (Optional) Set up Swap file

In some cases, you may run into problems due to not having enough physical RAM. To work around these problems, you can set up a Swap file, by following these instructions on How To Create A Linux Swap File.

## Convertkit Newsletter