Проблема, есть два сервера, всё настроено одинаково, но на втором сервере сервисы типа «PageSpeed Insights» пишут Исправьте обязательно:Включите сжатие. Судя по всему что то настроенно не одинаково, но не пойму что, далее конфиги 1 и 2
Сервер 1
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.4 (jessie)
Release: 8.4
Codename: jessie
nginx -V
nginx version: nginx/1.8.1
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled
configure arguments:
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-http_auth_request_module
--with-mail
--with-mail_ssl_module
--with-file-aio
--with-http_spdy_module
--with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-z,relro -Wl,
--as-needed'
--with-ipv6
site1.conf
server {
server_name 1.site.ru www.1.site.ru;
#Убрать / на конце страницы
location ~ .+/$ {
rewrite (.+)/$ $1 permanent;
}
# Убрать /////// на конце страницы
if ($request_uri ~ "^[^?]*?//") {
rewrite "^" $scheme://$host$uri permanent;
}
## редирект с www
if ($host ~* ^www\.(.+)$) {
set $newhost $1;
rewrite ^ http://$newhost$request_uri permanent;
}
charset utf-8;
access_log /var/log/nginx/site1.access.log;
error_log /var/log/nginx/site1.error.log;
root /var/www/site1/public/;
index index.php index.html index.htm;
client_max_body_size 100m;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.(css|js|gif|jpe?g|png|jpg|woff|svg)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /404.html;
error_page 500 /500.html;
location = /500.html {
root /var/www/site1/public/;
internal;
}
# location ~* ^/.+\.php {
location ~* ^/index\.php$ {
internal;
root /var/www/site1/public;
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/site1/public$fastcgi_script_name;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_key "$server_addr:$server_port$request_uri|$cookie_phpsessid";
fastcgi_cache fastcgi_cache;
fastcgi_temp_path /tmp/nginx/temp 1 2;
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
}
location ~* ^/.+\.php {
return 404; }
gzip on;
}
/etc/nginx/nginx.conf
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
fastcgi_cache_path /tmp/nginx/ levels=1:2 keys_zone=fastcgi_cache:16m max_size=256m inactive=1d;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Сервер 2
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.4 (jessie)
Release: 8.4
Codename: jessie
nginx -V
nginx version: nginx/1.8.1
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled
configure arguments:
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-http_auth_request_module
--with-mail
--with-mail_ssl_module
--with-file-aio
--with-http_spdy_module
--with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-z,relro -Wl,
--as-needed'
--with-ipv6
site.conf
server {
server_name site.ru www.site.ru;
#Убрать / на конце страницы
location ~ .+/$ {
rewrite (.+)/$ $1 permanent;
}
# Убрать /////// на конце страницы
if ($request_uri ~ "^[^?]*?//") {
rewrite "^" $scheme://$host$uri permanent;
}
## редирект с www
if ($host ~* ^www\.(.+)$) {
set $newhost $1;
rewrite ^ http://$newhost$request_uri permanent;
}
charset utf-8;
access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;
root /var/www/site/public/;
index index.php index.html index.htm;
client_max_body_size 100m;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.(css|js|gif|jpe?g|png|jpg|woff|svg)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /404.html;
error_page 500 /500.html;
location = /500.html {
root /var/www/site/public/;
internal;
}
# location ~* ^/.+\.php {
location ~* ^/index\.php$ {
internal;
root /var/www/site/public;
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/site/public$fastcgi_script_name;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_key "$server_addr:$server_port$request_uri|$cookie_phpsessid";
fastcgi_cache fastcgi_cache;
fastcgi_temp_path /tmp/nginx/temp 1 2;
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
}
location ~* ^/.+\.php {
return 404; }
gzip on;
}
/etc/nginx/nginx.conf
user nginx;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# proxy_cache_path /var/cache/nginx levels=2 keys_zone=pagecache:5m inactive=10m max_size=50m;
#
fastcgi_cache_path /tmp/nginx/ levels=1:2 keys_zone=fastcgi_cache:16m max_size=256m inactive=1d;
#
#
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
# gzip on;
include /etc/nginx/conf.d/*.conf;
}
Если сделать curl -I --compressed, строчка Content-Encoding: gzip присутствует
curl -I --compressed http://1.site.ru
Content-Encoding: gzip
curl -I --compressed http://site.ru
Content-Encoding: gzip
По логике всё должно работать, но видимо я что то упустил, есть идеи?