david
david

Reputation: 6805

How to specify a directory in nginx.conf to serve index.html from

I am trying to rewrite a very simple nginx.conf file. The only purpose of this project is to have nginx serve a static index.html on localhost.

Since all of the documentation and tutorials online have minimum 50 line configurations. I'm wondering if my 7 line configuration will work and accomplish what I need.

}    
  server {
    root /test/index
    listen 8888;
  }
}

Usually I just use the default nginx.conf and make modifications for whatever project I'm working on, so I'm not sure if I can strip out as much as I did here and have it still function?

Upvotes: 5

Views: 8833

Answers (1)

1sloc
1sloc

Reputation: 1180

You'll do best to include the server_name as well, and to end your statements with semicolons:

server {
    server_name some.server.name;
    listen 8888;
    # or just _ (underscore) to listen to any name
    root /test/index;
    index index.html;
}

Upvotes: 6

Related Questions