Run sudo apt install certbot python3-certbot-nginx
Proxypass your port exposed app
server{
server_name www.example.com;
location / {
proxy_pass http://www.example.com:8080;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
change the port accordingly, then check syntax with sudo nginx -t
Run sudo certbot --nginx -d www.example.com
and follow the instructions, accept redirection to allow http->https
automatically
sudo /etc/init.d/nginx restart
sudo kill -9 sudo lsof -t -i:80