Ghost Configuration Need www

OK, I am having an issue with the preconfigured Ghost image. What I want to do is use www with domain instead of naked. For example, I want instead

I first changed the /etc/nginx/sites-available/ghost file to server_name and changed the /var/www/ghost/config.js file in Production to: url: ', I then attempted to access the site. When using, I visit the site, but when I use, I get the Nginix Welcome screen.

I then attempted to change he /etc/nginx/sites-available/ghost file to server_name and got a bad gateway error 502 on and a 404 error on

I know this is a configuration error some place and I could spend hours playing around with it, but I’d prefer to ask here because I have a feeling it is a very easy to fix error.



Submit an 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.

I fixed this issue. It was a bear and took several hours to accomplish it so I am going to put it here so others Googling this issue can do what I finally did to solve it. This is a lot harder than it should be! I suspect most of the issue stem from the tutorials being ancient. While this took a lot of time to figure out, but with these commands this can take literally a few minutes.

The very first thing I had to do was move /var/www/ghost to /var/www/

I also had to run service ghost stop

then I edited the System startup files by nano /etc/systemd/system/ghost.service

I edited out the location /var/www/ghost to /var/www/

Now I edited configurations, you can see them below. After editing all of those, I rebooted the machine with shutdown -r now

I hope this can help someone else in the same predicament.

Here is my Config.js file with the pertinent parts—notice the port is different: config = { // ### Production // When running Ghost in the wild, use the production environment. // Configure your URL and mail settings here production: { url: ‘’, mail: {}, database: { … … server: { host: ‘’, port: ‘2778’ }

Here is my Nginx site configuration(notice there are two server blocks and the port in location has been changed. server { listen 80; listen [::]:80;

server_name; # Replace with your domain

root /usr/share/nginx/html;
index index.html index.htm;

client_max_body_size 10G;

location / {
    proxy_pass http://localhost:2778;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_buffering off;

} server { listen 80; server_name; return 301$request_uri; }


Add all domains to your server_name directive like this:


Hope this helps.