cd /etc/nginx/sites-available

tee -a missions.azaion.com << END
server {
    listen 443 ssl;
    server_name missions.azaion.com;

    ssl_certificate /etc/letsencrypt/live/missions.azaion.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/missions.azaion.com/privkey.pem;

    root /var/www/mission-planner;
    index index.html;

      location / {
        try_files \$uri /index.html;
      }

      error_page 404 /index.html;
}

server {
     listen 80;
     server_name missions.azaion.com;

     # Redirect all HTTP requests to HTTPS
     return 301 https://\$host\$request_uri;
}
END
ln -s /etc/nginx/sites-available/missions.azaion.com /etc/nginx/sites-enabled/

# create certs
certbot --nginx -d missions.azaion.com

mkdir /var/www/mission-planner
sudo chown -R www-data:www-data /var/www/mission-planner
sudo chmod -R 755 /var/www/mission-planner

systemctl restart nginx