I'm running into some inexplicable behavior with this config. I set a subdomain variable to a matching group from my server_name regex, and use it later in some rewrites and try_files. However, when I added the location block for static files: location ~* /.*/.*\.(jpg|jpeg|gif|css|png|js|ico|xml)$ The subdomain gets set to an empty string. Can somebody explain to me what is causing this?
Config:
server
{
listen 8080;
server_name ~^(?:\w*\.)?(\w+)\.domain\.com$;
set $subdomain $1;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log debug;
root /home/falltime/vhosts/falltime/public;
rewrite_log on;
index index.php;
try_files $uri $uri/ /index.php?route=$subdomain$uri;
location = /
{
rewrite ^ /index.php?route=$subdomain last;
}
location ~* /.*/.*\.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 1w;
}
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param QUERY_STRING $query_string;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param test $subdomain;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}