Uncategorised

Nginx Letsencrypt

This is still work in progress

Install Nginx and Certbot

Install Nginx and Certbot

sudo apt update
sudo apt install nginx python3-certbot-nginx

Create a folder for your site. Replace example.com with your domain

sudo mkdir -p /var/www/example.com
sudo nano /var/www/example.com/index.html
<!doctype html>
<html>
<head>
    <title>Hello</title>
</head>
<body>
    <h1>Hello World</h1>
</body>
</html>

Create a config file for your site.

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

Put this into the file above. Replace example.com with your domain

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

       server_name example.com;

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

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

Enable your site.

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

Check your config is correct

sudo nginx -t

Reload Nginx

sudo systemctl reload nginx

Set up Letsencrypt

sudo certbot --nginx -d example.com