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 http://www.example.com instead http://example.com
I first changed the /etc/nginx/sites-available/ghost file to server_name example.com and changed the /var/www/ghost/config.js file in Production to: url: 'http://www.example.com, I then attempted to access the site. When using example.com, I visit the site, but when I use www.example.com, I get the Nginix Welcome screen.
I then attempted to change he /etc/nginx/sites-available/ghost file to server_name www.example.com and got a bad gateway error 502 on example.com and a 404 error on www.example.com
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.
Thanks!
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!
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/example.com/ghost
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/example.com/ghost
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: ‘http://www.example.com’, mail: {}, database: { … … server: { host: ‘127.0.0.1’, 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 www.example.com; # 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 example.com; return 301 http://www.example.com$request_uri; }
Add all domains to your server_name directive like this:
server_name example.com www.example.com
Hope this helps.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.