Report this

What is the reason for this report?

Trouble with ghost, nginx and ssl

Posted on May 29, 2014

I am having epic troubles with getting ssl on my droplet with ghost, nginx. I created a droplet with ghost pre installed. It worked great. Then I grabbed a startssl certificate and followed the general instructions for install ssl on nginx

Now when I access http://blog.samjohnduke.com i get correctly redirected to https version. But nothing happens and after a minute or so it times out.

my nginx default.conf file is

server {
listen 80; listen 443 default ssl;
server_name blog.samjohnduke.com;

ssl_certificate /etc/nginx/ssl/blog.samjohnduke.com.chain.pem;
ssl_certificate_key /etc/nginx/ssl/blog.samjohnduke.com.key;

add_header Strict-Transport-Security max-age=31536000;
add_header X-Frame-Options DENY;

client_max_body_size 10M;
                                                                         
location / {                                                             
        proxy_pass http://localhost:2368/;                               
        proxy_set_header Host $host;                                     
        proxy_buffering off;                                             
}                                                                        

}

Thanks, Sam



This textbox defaults to using Markdown to format your answer.

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Answering my own question because I fixed it and people should know. <br> <br>I changed listen 443 default ssl; to listen 443; <br> <br>I added ssl on; just before the ssl_certificate directive <br> <br>I added <br> proxy_set_header X-Forwarded-Proto https; <br>just after proxy_pass in the location directive. <br> <br>this allowed me to have ssl enabled by default on every page. YAY!

Hi Sam,

I’ve just set up something similar to you, just thought I’d point out that you may run into issues with users hitting port 80 and getting errors because you’ve Strict-Transport-Security enabled.

Something like this might be a better option, redirecting all users from port 80 HTTP to port 443 HTTPS:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name www.example.com example.com;

    return 301 https://$server_name$request_uri;
}
server {
    listen 443 ssl;
    listen [::]:443 ipv6only=on;
    server_name www.example.com example.com;

    access_log   /var/log/nginx/www.example.com.access.log;
    error_log    /var/log/nginx/www.example.com.error.log;
	
    ssl_certificate /etc/nginx/ssl/www.example.com.chain.pem;
    ssl_certificate_key /etc/nginx/ssl/www.example.com.key;

    add_header Strict-Transport-Security max-age=31536000;
    add_header X-Frame-Options DENY;
	
    location / {
        proxy_pass http://localhost:2368;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }
}

This will make sure all requests are 100% SSL 100% of the time :)

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.