In my 0.x Ghost blog, I had a directory called static at /var/www/static. In it I have several documents that I link to on a ghost page. I upgraded to the 1.x version by creating a new server and installing a new version of Ghost. I imported all my information and copied over the files in the static directory. Now my new version of Ghost gives me a 404 when I try a link to the static documents in the static directory.
I added
location /static/ {
alias /var/www/static;
}
to the ghost/system/blogname.conf file, restarted ghost and nginx but that didn’t fix the problem. I also tried:
location /files {
root /var/www/static;
}
but still no go.
What am I missing? Is there a different file I need to modify?
You’re missing a trailing slash (/) on your /static/ location block alias. Try this:
location /static/ {
alias /var/www/static/;
}
Assuming your host is localhost, and you have a /var/www/static/doc.pdf, you’ll then be able to go to localhost/static/doc.pdf and have it served up.
If you wish to use root rather than alias, then you will need to omit the /static portion, otherwise it’ll end up searching for /var/www/static/static/doc.pdf (notice the double static directory). If you wish to use the root approach then you will want the following.
location /static/ {
root /var/www/
}
Note the trailing slash at the end of the location and the root again.
Thanks for the suggestion, however that didn’t fix the problem. I have tried it with and without the trailing / in both the location statement and in the actual directory location. No variation I have tried works. I didn’t have this problem in my pre 1.x versions. I believe my issue is with the root statement in the config on ver 1.x. Here is my config from /var/www/ghost/system/files/mysite.conf
The root statement points to a directory that does not exist and is not symlinked. How does that work? You can see my location statement later in the file. I have used root and alias to identify the directory but neither option works. I’ve even tried to put the location statement in the nginx.conf file in hopes that would get read first. Not only am I out of ideas, I’m not sure I understand how the root directory even works. The only thing I haven’t tried is to clear the cache but to be honest, I can’t figure out where it is located.
Any help you could give me would be greatly appreciated.