Regex Nginx动态vhost返回错误\u无效\u重定向

Regex Nginx动态vhost返回错误\u无效\u重定向,regex,nginx,vhosts,Regex,Nginx,Vhosts,我正在尝试将服务器设置为使用单个conf文件为所有开发站点提供服务。 因此,my/ect/nginx/site available/dev.example.com如下所示: server { listen 80; server_name ~^(?<folder>[^.]*).(?<user>[^.]*).dev.example.com; charset utf-8; index index.php index.html index.ht

我正在尝试将服务器设置为使用单个conf文件为所有开发站点提供服务。 因此,my/ect/nginx/site available/dev.example.com如下所示:

server {
    listen 80;

    server_name ~^(?<folder>[^.]*).(?<user>[^.]*).dev.example.com;

    charset utf-8;
    index index.php index.html index.htm;



    root /var/www/projects/dev/$user/$folder/htdocs;
    access_log /var/www/projects/dev/$user/$folder/access.log;
    error_log  /var/www/projects/dev/commons/logs/htdocs/error.log;

    location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|js|css)$ {
        access_log        off;
        log_not_found     off;
        expires           30d;
        add_header Pragma "public";
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }

    location ~ \.php$ {

            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param APPLICATION_ENV $user;
            include fastcgi_params;
   }


    location ~ /\.ht {
        deny all;
    }
}
服务器{
听80;
服务器名称~^(?[^.]*)(?[^.]*)。dev.example.com;
字符集utf-8;
index.php index.html index.htm;
root/var/www/projects/dev/$user/$folder/htdocs;
access_log/var/www/projects/dev/$user/$folder/access.log;
error_log/var/www/projects/dev/commons/logs/htdocs/error.log;
(ogg | ogg | ogv | ogg | ogv | ogg | ogg | ogg | ogg | ogg | ogv | ogv | ogv | svg | svg | SVG124政政政协| O夫124夫124夫瓦夫124政政政政协|沃夫夫124夫124夫|沃夫夫夫夫夫124政政政政政政政协1244 1244 124政政政政政协1244 124412441244124;瓦夫|瓦夫124政政政政政政政政政协1244{
访问/注销;
未发现注销日志;
过期30天;
添加标题Pragma“public”;
}
地点/{
try_files$uri$uri//index.php?$args;
授权基本“受限内容”;
auth\u basic\u user\u文件/etc/nginx/.htpasswd;
}
位置~\.php${
try_files$uri=404;
fastcgi\u split\u path\u info^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index.php;
fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
fastcgi_param应用程序_ENV$用户;
包括fastcgi_参数;
}
位置~/\.ht{
否认一切;
}
}
regexp工作正常,如果我使用带有phpinfo()的index.php运行该文件,看起来一切正常。。。但是如果我运行wordpress,我会得到ERR\u INVALID\u重定向

如果我在不使用regex的情况下更改文件/ect/nginx/site available/dev.example.com并设置绝对路径,那么一切都会正常工作


我缺少什么?

问题是变量服务器名称,该名称被解释为
~^(?[^.]*)(?[^.]*)。dev.example.com
要解决此问题,重写变量是有效的

fastcgi_param SERVER_NAME $folder.$user.dev.example.com;