NGINX泛解析conf文件


一个泛解析泛指向的nginx配置文件

server {
    listen 80;
    server_name example.com;
    rewrite ^/(.*)$ http://www.example.com;
}
server {
    listen 80;
    server_name *.example.com;
    set $package 'sandbox';

    if ($host ~* "^(abc|efg|123)\..*$") {
        return 301 https://$1.example.com$request_uri;
    }

    if ($host ~* "^([a-z0-9]+)\..*$") {
        set $package comexample$1;
    }

    index index.html index.htm index.php;
    root /ttdata/website/example/$package;
    
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;#php-fpm的默认端口是9000
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires 100d;
    }
    location ~ .*\.(js|css)?$ {
        expires 30d;
    }
    #ttkc denysvn and rewrite and logs
    location ~ .*.(svn|git|cvs){deny all;}
    location / {
        #coding more
        if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php last;
            break;
        }
    }
}

版权声明,转载请附上原文链接及本声明: https://blog.yongit.com/note/130092.html