"server" directive is not allowed here error

Reinis Rozitis r at roze.lv
Sun Jun 4 11:41:07 UTC 2017


> That can't be right, because before I used the multiple location directives, I
> didn't have http and it worked fine. Regardless, I followed your advice and I got
> the following now:

As people have already pointed you probably have something like main config nginx.conf  with:

http {
..
include sites-enabled/*;
..
}

where each separate config file indeed doesn't need an extra http {} but the different server{} blocks still end up being within a (single) http {}.


> nginx: [emerg] "http" directive is not allowed here in 
> /usr/local/nginx/conf/sites-enabled/ server.domain.tld -ssl:1

Nginx includes/parses the files in the order they appear in the directory (sites-enabled/) - as it was stated you might try to check if the server file before " server.domain.tld -ssl" has a correct configuration (all the braces {} are closed etc).

rr



More information about the nginx mailing list