requested domain name does not match the server’s certificate

February 28, 2018 8.7k views
Ubuntu Apache DigitalOcean Let's Encrypt Ubuntu 16.04

Hi all,

my requirement is i need to redirect from to

The url ( is the web application using flask

The error am getting while running from the browser is ** your connection is not secure uses an invalid security certificate. The certificate is only valid for the following names:,**

The following are the installation/configuration steps carried out:

My domain is registered in Godaddy
in Godaddy, the forwarding section we had added the URL
Forward Type: Permanent(301)
SETTINGS: Forward Only

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get install python-certbot-apache
sudo certbot –apache -d -d

certificates are generated in the following location


In the following location /etc/nginx/sites-available/default

The following is the change

    server {
    listen 80;
    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;


    location /.well-known {
            allow all;
            default_type "text/plain";
            autoindex    on;
            location / {
            return 301$request_uri;


  server {

   listen [::]:443 ssl ipv6only=on; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        location / {
          proxy_pass "";


In the following location /etc/nginx/sites-enabled/000-default.conf

The following is the change

    <VirtualHost *:443>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    Redirect permanent /
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


VI) In the following location /etc/apache2/sites-available/default

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    Redirect permanent /

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
     SSLEngine on
     SSLCertificateFile /etc/letsencrypt/live/
     SSLCertificateKeyFile /etc/letsencrypt/live/

In flask web application the following is the change

    if __name__ == '__main__':,ssl_context=('/etc/letsencrypt/live/','

Please suggest how can i resolve the error

Please suggest what best can be done to redirect to the https URL seamlessly

1 Answer

You cannot acquire a LetsEncrypt certificate for an IP address currently. You could either use a paid CA to issue a certificate for the IP address, reconfigure your control panel to use the domain name instead of the IP address or set up a reverse_proxy configuration in nginx to route the control panel access through it instead of redirecting it.

  • Thanks ryan…
    That was helpful,

    Can u confirm the steps to be taken from GoDaddy & Ubuntu (wrt Nginx) . Need yur help

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!