我有下一个nginx conf:
server {
listen 80;
server_name ~^(www\.)?(?<sname>.+?).site.ru$;
root /var/www/kvz/$sname.site.ru/web;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/static/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
}
# DEV
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
access_log /var/log/nginx/$sname-access.log;
error_log /var/log/nginx/$sname-error.log debug;
}
在我的static
目录中存在file.js和file.js.gz.但是当我请求file.js时,nginx不能提供file.js.gz.为什么?在this问题中写下了这项工作。我的配置有什么问题?