I have a new Ghost installation running on a VPS server, and everything seems to be working well. My issue is that I want to link from within the Ghost content to files I’ve uploaded manually to my server (in this case, older plain HTML files, PDF files, etc).
It’s not clear to me how I can go about this. If I put a file into the directory that Ghost was installed into, which I understand to be the document root, and then I link to that file, I receive a 404 error.
For example:
I upload uploadedfile.html to /var/www/ghostinstall
Part of the issue that I have is that many of the HTML files I need to upload have complex urls in them that use full URL paths, and so I need these files to be in the document root so that the hyperlinks within them still resolve correctly.
If anybody has any thoughts, I’d be most grateful.
You can solve this by configuring your web server to not pass a specific path to Ghost and instead serve that directory… directly. Here’s an example syntax for Nginx:
location /static/ {
alias /sites/mark.stosberg.com/content/static/;
}
There you can see I’ve told Nginx to map the /static directory to a particular directory inside my content folder. Adjust the paths to suit yourself.
And here’s how you might use it with a Ghost config (don’t forget to back up your existing config!)
// ...
location / {
try_files $uri @ghost;
}
// ...
location @ghost {
internal; // Tells nginx that this isn't a public route
// Config from `location /` block before it was changed
}