Можно ли использовать модуль Nginx PageSpeed вместе с SSI?
Я не могу запустить SSI, когда включен PageSpeed.
Но как только я отключаю PageSpeed, SSI снова работает:
location ~ .+\.html$ {
pagespeed off;
ssi on;
}
Я нашел способ обойти эту проблему.
server {
listen 80;
server_name app.local www.app.local;
access_log /var/log/nginx/www.app.local.access.log;
error_log /var/log/nginx/www.app.local.error.log;
index index.html index.htm;
autoindex off;
# Set the root directory to search for the file
root /home/deploy/app-directory/production;
# ------------------------------------------------------------------------------------
# @begin CONFIGURE PAGESPEED
# Needs to exist and be writable by nginx. Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }
pagespeed LoadFromFileMatch "^https?://(www.)?app.local" "/home/deploy/app-directory/production/";
# Disable CoreFilters
# pagespeed RewriteLevel PassThrough;
# Enable filters
# pagespeed EnableFilters combine_css,extend_cache,flatten_css_imports,rewrite_images,prioritize_critical_css,remove_comments;
# @end CONFIGURE PAGESPEED
# ------------------------------------------------------------------------------------
# ...
# Proxy html requests to a server located on port 90
# This is a workarround to get PageSpeed working together with SSI
location ~ ^/[^/]+\.html$ {
pagespeed on;
proxy_pass http://127.0.0.1:90$uri;
# proxy_pass http://127.0.0.1:90$uri$is_args$args;
}
}
# Define a server only for html files with SSI support
# This is a workarround to get PageSpeed working together with SSI
server {
listen 90;
server_name app.local www.app.local;
access_log /var/log/nginx/www.app.local.access.log;
error_log /var/log/nginx/www.app.local.error.log;
index index.html index.htm;
autoindex off;
# Set the root directory to search for the file
root /home/deploy/app-directory/production;
location / {
allow 127.0.0.1; deny all;
ssi on;
}
}
Вы можете найти более подробную информацию в списке рассылки где я разместил тот же вопрос.