Question

Host non-Ghost webpage with Nginx and Ghost

Posted June 18, 2014 3.9k views
Hi everyone, I just installed ghost and I am having some trouble hosting some non-ghost content on my server. I would like to have ghost as homepage, but host in (example) /var/www/static a PDF file, or another HTML page. I sincerely do not know what to do. Reading around I tried to change my /etc/nginx/conf.d/default.conf
server {
    listen 80;
    server_name nicolacarboni.com;
    root /var/www/ghost/content/themes/chiara;

    location / {
        try_files $uri @proxy;
    }

    location @proxy {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}
In order to host on /var/www/ghost/content/themes/chiara static files, but it does not work... Do you have some solutions?

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.

×
1 answer
You can set this up with an alias directive in your Nginx configuration:
server {
    listen 80;
    server_name nicolacarboni.com;
    root /var/www/ghost/content/themes/chiara;

    location / {
        try_files $uri @proxy;
    }

    location @proxy {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }

    location /static/ {
            alias /var/www/static/;
    }
}
Submit an Answer