SSL with certbot on nginx/apache on Ubuntu Server

First Thing first

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update

On Nginx Server

sudo apt-get install python3-certbot-nginx
sudo certbot --nginx

On Apache Server

sudo apt-get install python3-certbot-apache
sudo certbot --apache

Note [if using Cloudflare]: If you have used cloudflare as DNS hosting and have proxied your DNS record to this server, then automatic domain verification of while generating certificate will fail. In this case remove proxy from cloudflare DNS record and then try again else you can choose other methods for your domain verfication