我可以将 Nginx PageSpeed 模块与 SSI 一起使用吗?

我可以将 Nginx PageSpeed 模块与 SSI 一起使用吗?

是否可以将 Nginx PageSpeed 模块与 SSI 一起使用?

当启用 PageSpeed 时,我无法启动并运行 SSI。

但是,一旦我禁用 PageSpeed,SSI 就会再次起作用:

location ~ .+\.html$ {
  pagespeed off;
  ssi on;
}

答案1

我找到了解决此问题的方法。

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

您可以找到更多详细信息在邮件列表中我在那里发布了同样的问题。

相关内容