Deploy static website with git
On server
# create directory for content
cd /var/www/
sudo mkdir frny.uk
sudo chown -R <user>:sudo frny.uk
# create directory for git repo (difficult to git push to outside home - maybe the chown above would have worked)
mkdir -p ~/repos/frny.uk.git
cd ~/repos/frny.uk.git/
git init --bare
# create hook
cd hooks
vi post-receive
#!/bin/sh
git --work-tree=/var/www/frny.uk --git-dir=/home/<user>/repos/frny.uk.git checkout -f main
chmod +x post-receive
On local machine
# add remote pointing to server
git remote add deploy ssh://<user>@<server>.vps.webdock.io/~/repos/frny.uk.git/
git push deploy
Setup SSL with wildcard SSL cert
sudo certbot certonly --email <user>@example.com --manual --preferred-challenges=dns -d *.frny.uk --server https://acme-v02.api.letsencrypt.org/directory
sudo vi /etc/nginx/sites-available/frny.uk.conf
# see end
sudo ln -s /etc/nginx/sites-available/frny.uk.conf /etc/nginx/sites-enabled/frny.uk.conf
sudo nginx -t
sudo systemctl reload nginx
frny.uk.conf
server {
listen 80;
listen [::]:80;
server_name frny.uk ~^(.*)\.frny\.uk$;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
root /var/www/frny.uk;
index index.html;
server_name frny.uk www.frny.uk;
ssl_certificate /etc/letsencrypt/live/frny.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/frny.uk/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 443 ssl;
root /var/www/frny.uk/$1;
index index.html;
server_name ~^(.*)\.frny\.uk$;
ssl_certificate /etc/letsencrypt/live/frny.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/frny.uk/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
try_files $uri $uri/ =404;
}
}
Renew SSL cert
sudo certbot certonly --manual -d *.frny.uk
sudo nginx -t
sudo systemctl reload nginx