By ac130nz
I am trying to get ghost to run from example.com/blog instead of just example.com
I am now getting a ghost 404 on http://example.com/blog/ and the default nginx home page on http://example.com/
I used DO’s one click installer and had ghost running before I tried this. I have looked at all info I could find on DO and ghostforbeginners.com
This is what I did:
nano /etc/nginx/sites-available/ghost
changed the location / to location /blog here:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name http://example.com; # Replace with your domain
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 10G;
location /blog {
proxy_pass http://localhost:2368;
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;
}
}
Then saved it and nano /var/www/ghost/config.js changed the production url be have http://example.com/blog/
production: {
url: 'http://example.com/blog/',
mail: {},
database: {
...
Then I restarted everything
sudo service nginx restart
These didn’t work or help me: https://www.ghostforbeginners.com/how-to-install-ghost-in-a-subdirectory/ and https://www.digitalocean.com/community/questions/adding-ghost-blog-to-existing-website and https://www.digitalocean.com/community/questions/how-to-put-ghost-blog-as-subdirectory-on-page
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!
Hi @ac130nz
Try this server-block instead, just like the article on Ghost for Beginners:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name example.com; # Should only be the domain, not with http
root /usr/share/nginx/html;
index index.html index.htm;
location ^~ /blog {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}
}
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.