Welcome! Log In Create A New Profile

Advanced

Re: "server" directive is not allowed here error

oscaretu .
June 04, 2017 09:10AM
Hello, Peter.

In the company where I work the file nginx.conf is bigger than 1 MB. Por
each virtual server, there are lots of definitions that are almost equal.
If I where the one who had to decide the file structure, I problably choose
to use a different file for each virtual host, so when we have to create a
new one, I just use a perl script to create the new one using some
substitutions in one of the existing ones. So it is easy for my to watch
the differences using a program like *meld* (or *tkdiff*, *kompare *or
similar)

There is a diffent approach, that is the inverse process: i've created a
script that splits the whole nginx.conf file to create an individual file
for each virtual host, and then I can compare a virtual host with another
one using meld in a easy way. Then I delete all the individual temporal
files.

I think than having small files is less error-prone...

Kind regards,
Oscar

On Sun, Jun 4, 2017 at 2:58 PM, Peter Booth <peter_booth@me.com> wrote:

> FWIWI have never understood the desire to have nginx configuration spread
> across multiple files.
> It just seems to invite error and make it harder to see what is going on.
>
> Perhaps if I worked for a hosting company I’d feel differently but on the
> sites that I have worked on,
> even with quite complicated, subtle caching logic the entire nginx.conf
> has been under 600 lines - not
> that different from a default Apache httpd.conf but with all configuration
> not 90% comments
>
>
> > On 4 Jun 2017, at 7:41 AM, Reinis Rozitis <r@roze.lv> wrote:
> >
> >> 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
> >
> > _______________________________________________
> > nginx mailing list
> > nginx@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



--
Oscar Fernandez Sierra
oscaretu@gmail.com
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

"server" directive is not allowed here error

Dino Edwards June 03, 2017 09:40AM

RE: "server" directive is not allowed here error

Reinis Rozitis June 03, 2017 02:22PM

RE: "server" directive is not allowed here error

Dino Edwards June 04, 2017 06:30AM

Re: "server" directive is not allowed here error

Anoop Alias June 04, 2017 06:32AM

Re: "server" directive is not allowed here error

Jim Ohlstein June 04, 2017 06:38AM

RE: "server" directive is not allowed here error

Reinis Rozitis June 04, 2017 07:42AM

Re: "server" directive is not allowed here error

pbooth June 04, 2017 09:00AM

Re: "server" directive is not allowed here error

oscaretu . June 04, 2017 09:10AM

Re: "server" directive is not allowed here error

Anoop Alias June 04, 2017 09:16AM

RE: "server" directive is not allowed here error

Reinis Rozitis June 04, 2017 09:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 185
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready