5

So I want to serve static files from a specific folder on a specific port with Nginx.

$ nginx -c `pwd`/nginx.conf 

my local nginx.conf goes like:

http { server { root .; listen 8080; } } 

but i'm getting this error:

nginx: [emerg] no "events" section in configuration 

I can see the events section in /etc/nginx/nginx.conf but I don't want to have to duplicate all the configuration. There has to be a way to use the default settings and just different port number for a specific folder.

What am I missing to get this to work?

1 Answer 1

5

You need to specify minimal events block:

events { worker_connections 1024; } 

Root needs to be declared with absolute path on the filesystem.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually root support relative path: see this answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.