Home > Linux, Nginx, Хостинг > Simple regular expression for Nginx virtual hosting configuration

Simple regular expression for Nginx virtual hosting configuration

Domain path: /www/domain.com/www/root/

## Servers
server {
        listen          80 default;
        server_name     localhost;
        index index.php;
 
        if ($host ~* "([^\/]+)\.([^\.\/]+\.[^\.\/]+)" ) {
                set $prefix /$2/$1/root;
        }
        root    /www$prefix;
 
        location ~ \.php$ {
                fastcgi_pass  CGI_FARM_NAME_HERE;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
                fastcgi_read_timeout 120;
                fastcgi_next_upstream error timeout invalid_header;
                include         fastcgi_params;
        }
 
        location ~ /\.ht { deny  all; }
 
        location ~* \.(jpg|jpeg|gif|png|swf|ico)$ {
                gzip off;
                expires         5d;
        }
 
        location ~* \.(js|css)$ {
                expires         6d;
        }
}
Categories: Linux, Nginx, Хостинг Tags:
Вижте всички статии от
Technology lover
Този автор е написал 156 статии