Black Pine

Add new website in Nginx and set up SSL

Add new website in nginx and set up SSL with certbot

Add new website

Domain: example.com

Files in: /var/www/example.com

Create Nginx config

sudo nano /etc/nginx/sites-available/example.com

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

    server_name example.com www.example.com;

    root /var/www/example.com;
    index index.html;

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

Enable the site

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

Permissions

sudo chown -R www-data:www-data /var/www/example.com
sudo find /var/www/example.com -type d -exec chmod 755 {} \;
sudo find /var/www/example.com -type f -exec chmod 644 {} \;

Test and reload Nginx

sudo nginx -t
sudo systemctl reload nginx

Enable HTTPS

sudo certbot --nginx -d example.com -d www.example.com

Verify

https://example.com

Check renewal manually:

sudo certbot renew --dry-run