Why doesn't this work?

Michael Shadle mike503 at gmail.com
Thu Jun 25 07:12:40 MSD 2009


On Wed, Jun 24, 2009 at 7:49 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:

>    server {
>        listen 80;
>        server_name ~^(.*?)\.mike\.foo\.com$;
>
>        set $name "";
>        if ($host ~ ^(.*?)\.mike\.foo\.com$) {
>            set $name $1;
>        }
>
>        ...
>    }

This doesn't seem to work for me.

server {
        listen 80;
        index index.php index.html;
        server_name ~^(.*?)\.%%USER%%\.foo\.com$;

        set $name $1;
        root /home/%%USER%%/web/$name;

#       set $name "";
#       if ($host ~^(.*?)\.%%USER%%\.foo\.com$) {
#               set $name $1;
#       }
                location / { }
                include /etc/nginx/defaults.conf;
                include /etc/nginx/confs/development.conf;
                include /etc/nginx/expires.conf;
                location ~ \.php$ {
                        include /etc/nginx/fastcgi.conf;
                        fastcgi_pass 127.0.0.1:%%PORT%%;
                }
                try_files $uri $uri/ /controller.php?uri=$uri&$args;
    }

Location isn't allowed inside of an "if"

$host isn't recognized: [emerg]: invalid condition "$host" in
/etc/nginx/nginx.conf

etc...





More information about the nginx mailing list