M
M
Maxim Barulin2017-05-25 10:02:28
Nginx
Maxim Barulin, 2017-05-25 10:02:28

Why is nginx not serving gz files?

I have the following nginx config:

config
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;

}

The static directory contains *.js and *.js.gz files with the same modification date.
But when requesting .js .gz is not returned.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question