ngx_pagespeed and proxy_pass ignores images

35 views
Skip to first unread message

Klaus Hebsgaard

unread,
Jun 11, 2021, 6:01:59 AMJun 11
to ngx-pagespeed-discuss
I am trying to use nginx as a reverse proxy in front of my image server.
I would use it with pagespeed to get better images, so for instance chrome would be served webp images instead of jpegs.
However I can't seem to get pagespeed to react to images.
When I get a 404 or html with a  http 200 response I get a fine "X-Page-Speed: 1.13.35.2-0" header.
But when I get an image pagespeed seems to ignore my request, this is my nginx conf - what am I doing wrong?


worker_processes  1;

events {
  worker_connections  1024;
}

http {

  server {

    pagespeed on;

    #pagespeed Disallow "/admin*"

    pagespeed FileCachePath "/var/ngx_pagespeed_cache";

    pagespeed FileCacheSizeKb 102400;

    pagespeed FileCacheCleanIntervalMs 3600000;

    pagespeed FileCacheInodeLimit 50000;

    pagespeed EnableCachePurge on;

    pagespeed PurgeMethod PURGE;


location "/" {


      proxy_pass http://server_ip:8080;

      proxy_set_header Host "images.example.com";
      # only added for debug purposes
      add_header  X-Upstream  $upstream_addr;
      # Mark HTML as uncacheable.
      proxy_hide_header Cache-Control;

      }

location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {

  add_header "" "";

}

location ~ "^/pagespeed_static/" { }

location ~ "^/ngx_pagespeed_beacon$" { }


    }
}

Longinos

unread,
Jun 12, 2021, 7:16:33 AMJun 12
to ngx-pagespeed-discuss
Hi
What kind of request do you do?
If the request are the images himself, the pagespeed optimizations are limited to those that IPRO can do. So no url change.
Pagespeed module works with resources in a html file and need to be public cacheable, with a cache-control header non 0.

Klaus Hebsgaard

unread,
Jun 15, 2021, 3:11:47 AMJun 15
to ngx-pagespeed-discuss
The Requests I am trying to make are to the images themselves.
They are primary jpeg images.
I only route the images through nginx.

Longinos

unread,
Jun 17, 2021, 5:22:21 AMJun 17
to ngx-pagespeed-discuss
Hi
So pagespeed module  work is limited to those optimizations that IPRO can do
To check if PRO is working check the Etag header it must be some like "PSA/xxxxx"
As a test you can make a html page with url to images and see what happens
Reply all
Reply to author
Forward
0 new messages