Why doesn't this work?

Maxim Dounin mdounin at mdounin.ru
Thu Jun 25 07:51:14 MSD 2009


Hello!

On Wed, Jun 24, 2009 at 08:12:40PM -0700, Michael Shadle wrote:

> 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$) {

-         if ($host ~^(.*?)\.%%USER%%\.foo\.com$) {
+         if ($host ~ ^(.*?)\.%%USER%%\.foo\.com$) {

Maxim Dounin

> #               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