Fundamental mod-pagespeed CDN question

28 views
Skip to first unread message

Vinson G

unread,
Oct 8, 2017, 2:53:51 AM10/8/17
to mod-pagespeed-discuss


I've literally spent days trying understand how the pagespeed module works with a CDN and I think I'm close but it looks like bad news for me.

Here's my situation - I have a website running nginx on an AWS server.  Most of the images that this website references are on a CDN (cloudfront) with an s3 origin.  NONE of these images are on the nginx server. 

Those images are horribly un-optimized.  Can pagespeed help in this case?  


I could see it gallantly trying to optimize these images but I'm failing terribly trying to get it update the references properly (here I am using s3 directly, but it shouldn't matter?): 


the above rewritten url throws up a 404.


It seems pagespeed is creating these optimized files on the nginx server (the pagespeed cache directory) but I don't now how to refer to them without these assets ever existing there originally. 


I found this on the nginx server:
/var/cache/pagespeed/v3/rate.com/http,3A/,2Fwww-test.rate.com/grate-cms/x3b052946-a928-42b0-b389-ff1848b38bde_hero-bg-image1.jpg.pagespeed.ic.8jtm2YhDaI.webp,

I feel it's so close!  but maybe I'm misunderstanding something fundamental. 

Joshua Marantz

unread,
Oct 8, 2017, 11:33:09 AM10/8/17
to mod-pagespeed-discuss
I think you're close too, but to fully get what you want, you will need to configure CloudFront to point to the server running ngx_pagespeed rather than directly to S3.

Then, on your ngx_pagespeed server, you want to use MapProxyDomain, to map the images served from an S3 origin into a URL path on your ngx_pagespeed server, and then rewrite them to CloudFront so you get the CDN effect.  This will be something like:
   pagespeed MapProxyDomain YOUR_NGX_SERVER_RUNNING_ON_AWS/s3_images YOUR_S3_SERVER/image_subdirectory YOUR_CLOUDFRONT_CDN/s3_images;

Please read the doc for details, and remember you also have to point YOUR_CLOUDFRONT_CDN/s3_images to use YOUR_NGX_SERVER_RUNNING_ON_AWS/s3_images as its origin.  Hope this makes sense!  Please let us know how it goes.

-Josh

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/a024d3ef-c1a9-4cd6-939e-061479a1fe83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vinson G

unread,
Oct 8, 2017, 3:08:07 PM10/8/17
to mod-pagespeed-discuss

Thanks! I was worried it wasn't really possible. I'm gonna check this out today and go all night if I have to. :)

Vinson G

unread,
Oct 9, 2017, 2:13:17 AM10/9/17
to mod-pagespeed-discuss


So this seems to be working for our CMS images: 
That re-written URL is now working. 

I still have some issues to resolve but this part seems to be working fine.  Thanks so much for the help!
Reply all
Reply to author
Forward
0 new messages