I have an Ubuntu 20.04 server running with Apache and Nginx. I want to add an SSL certificate using Certbot but I don't know how to proceed.

My project consists of a django api and a Vue js frontend. Nginx is responsible for the API and apache acts as a reverse proxy.

My Apache 000-default.conf file

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

<VirtualHost *:80>
    ServerName ***.***.** <- My IP
    ProxyPass /
    ProxyPassReverse /

My Nginx config

upstream django {
    server unix:///home/backend/mysite.sock;

server {
    listen      8000;
    server_name mysite.com;
    charset     utf-8;

    client_max_body_size 75M;

    location /media  {
        alias /home/backend/media;

    location /static {
        alias /home/backend/static;

    location / {
        uwsgi_pass  django;
        include     /home/backend/uwsgi_params;

Thank you if someone informs me how can I install an ssl certificate with Certbot using this configuration


1 Answer 1


Follow below steps to configure SSL with certbot.

  1. Install certbot

    sudo apt install python-certbot-apache
  2. Make sure DNS records pointing to your server and then generate certificate

    sudo certbot --apache -d domain.com -d www.domain.com
  3. If sucessfull it will produce below output and prompt for http to https redirection

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. ------------------------------------------------------------------------------- 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. ------------------------------------------------------------------------------- Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

  1. Select appropriate number as per your requirement. Once finished it will load certficate in apache automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.