ngx_pagespeed and proxy_pass ignores images

Skip to first unread message

Klaus Hebsgaard

Jun 11, 2021, 6:01:59 AM6/11/21
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:" 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 "";
      # 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$" { }



Jun 12, 2021, 7:16:33 AM6/12/21
to ngx-pagespeed-discuss
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

Jun 15, 2021, 3:11:47 AM6/15/21
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.


Jun 17, 2021, 5:22:21 AM6/17/21
to ngx-pagespeed-discuss
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
0 new messages