[DevOps] Running Ghost Blog on www and non www Host URLs

I ran into a slight problem when running Ghost on my server. The issue occurred when I tried to log into the admin interface (/ghost). It complained about my URL, giving me the following error:

Access Denied from url: unenglishable.com. Please use the url configured in config.js

I popped open the Chrome developer console and found that I was getting redirected from www.unenglishable.com to unenglishable.com. My config.js url was set to https://www.unenglishable.com, but my certificate is only valid for unenglishable.com, so Chrome was redirecting to where the certificate was valid for. (I recently switched to Let's Encrypt's SSL service, Certbot)

I fixed this issue by changing my nginx config to point both unencrypted http://www.unenglishable.com and http://unenglishable.com to SSL-encrypted https://unenglishable.com via reverse proxy. I then updated my config.js to have url: 'https://unenglishable.com. With redirect, I can now visit either www or non www and everything works just fine.

Hope this helps!

Resolves:
Access Denied from url: [url]. Please use the url configured in config.js