Question

Trouble with ghost, nginx and ssl

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

Show comments

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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 :)

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!