Nginx – Serving static directory on subdomain with assets


I have a html presentation which I would like to serve on a subdomain on my server. It just consists of some static html files and some assets (the Github is here).

I'm trying to write an nginx config file which will serve the presentation. What I have so far is the following:

server {

  root /home/dtuite/stuff/presentations/make_js_like_ruby/introduction;

  access_log off;
  error_log off;

The actual root file is in /introduction/index.html. Nginx seems to serve that file by default which is fine. The problem is that none of the assets seems to be available on the page. You can see the problem live here..

How do I make the assets are available but also make sure that the subdomain roots to the index file correctly?

Best Answer

Move Root Path

Your current directory structure (on your hard drive) is like following


However, your root path is set to


The web server will not access any file outside that path. Since themes, images, etc., are all outside the above path, their content will not be served.


I suggest moving the root path one level up

root /home/dtuite/stuff/presentations/make_js_like_ruby;

Then move the index.html into /home/dtuite/stuff/presentations/make_js_like_ruby. Of course links within index.html will have to be modified accordingly.