Ghost www redirecting to nginx index.html DigitalOcean

Edit: Resolved

I installed Ghost via 1-click image on DigitalOcean. However after I followed instructions the site is not accessible from www subdomain, only denimandleather.me

It seems to redirect to var/www/html/index.html instead of Ghost.

I tried rebuilding 1-click image several times but got different errors. I also installed SSL using certbox.

I also tried not using certbox and using Ghost’s built in SSL setup but requests that were sent to http: instead of https: were not redirected and resulted in ghost not loading. Editing /var/www/ghost/config.production.json and forcing https caused https://www.denimandleather.me to produce an error (invalid SSL certificate).

Configuration files are:

etc/nginx/sites-available

Current configuration etc/nginx/sites-available/default lists the servers.

I used certbot to install SSL certificate, with /var/www/ghost/config.production.json forcing https.

I’d like all domains all to load the blog page properly instead of giving “Welcome to nginx!” message, and also always redirect to https and to make sure the SSL certificate is auto-renewed every 3 months.

Now it looks like both denimandleather.me and www subdomain to both display the nginx welcome page instead of Ghost.

Help!

Paul

Hey Paul!

In order to setup ssl with ghost, you need to configure your site to run with ssl -

ghost config set url https://denimandleather.me
ghost setup nginx (it will ask if you want to set up ssl, and do it)

Check out this section in the docs for information regarding multiple domains

I know this doesn’t 100% answer your question, but it will hopefully push you in the right direction :smile:

2 Likes

Wow that fixed it, what a pain to resolve the common www. part of the name ;p

Thank you! This was also confusing me.

@acburdine / @Aileen could we have Ghost-CLI just do this in the background? I can’t think of a case where you would ever not want to just redirect the www or non-www version? :thinking:

eg.

if using a domain which does-not start with www:
Automatically setup and redirect www.domain.com => domain.com

if using a domain which does start www:
Automatically setup and redirect domain.com => www.domain.com

Could potentially also add a line to the CLI output to indicate this has happened in the background?

4 Likes

I don’t know how those one click server work because I’ve never tried one, but if you have access to your server via root, I would use Certbot, I’m going to include below a guide from my blog that goes over how to have ssl on any website, not only ghost.

The method that @vikaspotluri123 mentioned is one way, I personally installed Cerbot and then configured the domain to have ssl, if you go to nginx, you’ll see the changes. After configured it can redirect all the http requests to https :slight_smile:

I think that’s a cleaner way to set it up

https://elkepon.com/how-to-set-up-lets-encrypt-with-nginx-server-blocks-on-ubuntu-16-04/

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Sorry for the delayed response to this - definitely think it’s doable to automatically create that redirect.

1 Like