How to edit nginx config files

Hi,

I am a complete noob to Ghost and web development/terminal.

I have set up my own Ghost blog using the one-click installation on Digital Ocean. I have created a CNAME record for my domain so I can use www. for my domain and see that I require a SSL cert for that also.

I am following the SSL for additional domains. guide and am up to:

# Edit the nginx config files for your second domain to redirect to your canonical domain. In both files replace the content of the first location block with:
return 301 https://my-canonical-domain.com$request_uri;

I do not understand what I have to do, when I put the above command in the terminal with my original domain e.g. website.com, the terminal responds with a:

-bash: return: too many arguments

error message.

How am I supposed to

Edit the nginx config files for your second domain to redirect to your canonical domain. In both files replace the content of the first location block with:

How do I access the ngix files and how do I edit/save them?

Any help would be appreitated.

Thanks.

I believe I am now in the correct directories:

    ssl_certificate /etc/letsencrypt/www.website.com/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/www.website.com/www.website.com.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;

    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

What exactly am I supposed to change/delete?

Hey, I am also totally new at this but I’ve been thrashing around in a few docs recently and recalled that one of them stated that this can be found in /etc/nginx/sites-available/ so cd to that
The files themselves will be something like the below, edit the ones you need to make the change on which is dependant on your config.

yourdomain.com-ssl.conf  
yourdomain.com.conf  
www.yourdomain.com-ssl.conf  
www.yourdomain.com.conf

Hope this helps

1 Like