Used Let's Encrypt to secure Ubuntu 14.04/Nginx server (failed tutorial)

October 11, 2016 272 views
Nginx Let's Encrypt Ghost Ubuntu

I followed the DO tutorial "How to secure Nginx with Let's Encrypt on Ubuntu 14.04," but when I open my site in the browser (Firefox) it does not show as secure (https://). The certbot tells me that I have a valid cert. All the .pem files are present. I am at a loss. I am running Ghost 0.11.1 on Ubuntu 14.04 Nginx.

2 comments
  • Are you able to access your site by going to https://yourdomain.com? If so then it just sounds like you need to set up an automatic redirect from http to https which we can help you with here.

    If the site is completely unavailable via https then it indicates that there is something more serious wrong. I would recommend sharing the configuration files in /etc/nginx/sites-enabled if that is the case so we can review them and look for a cause.

  • Ok here is my ghost config file in the /etc/nginx/sites-enabled location:

    server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        server_name example.com www.example.com; # Replace with your domain
    
       root /usr/share/nginx/html;
       index index.html index.htm;
    
       client_max_body_size 10G;
    
       location / {
            proxy_pass http://example.com:2368;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_buffering off;
        }
    }
    

    The only config files the tutorial told me to edit was the /etc/nginx/sites-available/default, so there are presently no modifications to this file. I have replaced my domain with example.com, however.

    I cannot access my site from the browser by typing https:// first, so, as you said, there is probably a much larger problem. Thanks for any help you can give me!

2 Answers
xMudrii October 11, 2016
Accepted Answer

Are you sure you followed whole tutorial you linked?
As far as I see, there is no any directive for SSL. Also it is listening on HTTP (80) port instead of HTTPS (443). [How To Secure Nginx with Let's Encrypt on Ubuntu 14.04] describes what you need to change in Nginx config file to use SSL.

First of all make sure you created Diffie-Hellman Group located at /etc/ssl/certs/dhparam.pem.
If you did it, make sure you follow said tutorial from Step 3 — Configure TLS/SSL on Web Server (Nginx).

Your server block should look something like:

/etc/nginx/sites-enabled
server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    server_name example.com www.example.com; # Replace with your domain

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

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 10G;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;

location / {
    proxy_pass http://allthemoore.com:2368;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_buffering off;
}
# Redirect all HTTP (80) traffic to HTTPS (443)
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name example.com www.example.com;
    return 301 https://www.$server_name$request_uri;
}

If you created some other config file in /etc/nginx/sites-available make sure you made symbolic link from /etc/nginx/sites-available/example.com to /etc/nginx/sites-enabled. Also make sure old one is disabled.

Make sure you restarted or reloaded nginx sudo systemctl restart nginx.
Don't forget to change example.com to your domain ;)

That did it! I had improperly linked the /etc/nginx/sites-available/example.com to /etc/nginx/sites-enabled/example.com. Thanks for the help!!!

Have another answer? Share your knowledge.