Welcome! Log In Create A New Profile

Advanced

Re: include in if

Maxim Dounin
August 25, 2010 07:42AM
Hello!

On Wed, Aug 25, 2010 at 07:09:09AM -0400, ddarko wrote:

> nginx version: nginx/0.8.49
>
> I would like to serve static files by default, in the absence -
> uwsgi_pass.
> So I wrote this:
>
> server {
> listen 80;
> server_name www1;
> location / {
> root /var/www/1/public;
> if (!-f $request_filename) {
> include /etc/nginx/params_uwsgi;
> uwsgi_pass unix:/var/www/1.sock;
> }
> }
> }

root /path/to/server/root;

location / {
try_files $uri @fallback;
}

location @fallback {
include /path/toparams_uwsgi;
uwsgi_pass ...;
}

> Unfortunately, I have:
> Restarting nginx: [emerg]: "include" directive is not allowed here in
> line 7.
>
> would it not be able to do "include" inside "if" ?!
> any advice ?

Short answer: because "if" is ugly hack, see
http://wiki.nginx.org/IfIsEvil.

Long answer: "include" isn't something special per config file
syntax, and should be explicitly supported by every directive
which takes block as argument. In it's turn "if" takes block as
argument and doesn't explicitly support "include". And nobody is
willing to dig into it due to already outlined reasons (see short
answer).

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

include in if

ddarko August 25, 2010 07:09AM

Re: include in if

Maxim Dounin August 25, 2010 07:42AM

Re: include in if

ddarko August 25, 2010 12:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 113
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