Docker Part Two: How to provision a VPS, install Nginx, and configure SSL

We're going to provision a fresh server, install Nginx, and auto-configure SSL.

I'll assume you have a domain name for this and a choice of VPS provider. There's loads of choices out there like AWS, DigitalOcean, etc, but for this tutorial I will be using Scaleway.

Step 1 - Log onto Scaleway & SSH into your machine

Step 2 - Upgrade system

apt update && apt upgrade -y

Step 3 - Install Nginx

apt install nginx -y

Step 4 - Create a test html file to serve

If you want to host multiple domains on one server, ensure you create subdirectories. Replace with your domain

mkdir -p /var/www/

Let's now edit said file

nano /var/www/

Add in some basic HTML to start

        <title>Welcome to</title>
        <h1>Hello World!</h1>
        <p>You have accessed the website.</p>

Step 6 - Create a server to distribute files

nano /etc/nginx/sites-available/

Within this, add in the following

server {
        listen 80;
        listen [::]:80;

        root /var/www/;
        index index.html index.htm;


        location / {
                try_files $uri $uri/ =404;

Important: Edit the lines root and server_name according to your domain name.

Step 7 - Symbolic link sites-available to sites-enabled

ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Step 8 - Verify and reboot server

nginx -t
systemctl restart nginx

You should now see your server over http

Step 9 - Install SSL using Certbot

Get the latest package repo

add-apt-repository ppa:certbot/certbot

Install certbot for nginx

apt install python-certbot-nginx -y

Launch the wizard

certbot --nginx -d -d