Yet starting nginx fails and my log shows:
[emerg] 55#55: "server" directive is not allowed here in /etc/nginx/nginx.conf:1
What am I doing wrong? Not sure if it matters but this is inside a docker container.
Yet starting nginx fails and my log shows:
[emerg] 55#55: "server" directive is not allowed here in /etc/nginx/nginx.conf:1
What am I doing wrong? Not sure if it matters but this is inside a docker container.
/etc/nginx/nginx.conf
is not the place to store your server setups. This file should contain information on the user it will run under and other global settings. Typically it will contain stuff like this:Where you should put your individual server setups, is in
/etc/nginx/sites-enabled/
. As you can see, all files inside that folder are being included in thehttp
block of yournginx.conf
file.So store the sample config you have posted inside
/etc/nginx/sites-enabled/some-random-name.conf
, and restore thenginx.conf
file to the config I posted above, for instance, and you should be good to go.Try debugging first with
If this passes but nginx restart fails, try checking your nginx logs at narrow down the bug