incubator-pagespeed-ngx icon indicating copy to clipboard operation
incubator-pagespeed-ngx copied to clipboard

Recommended setup for reverse-proxy

Open luison opened this issue 1 year ago • 0 comments

Hi. We've been using mod_pagespeed for a while on our nginx reverse proxy balancer.

We have now performed some important changes removing apache on the upstream and migrating rewrites rules and I am wondering if someone with a similar setup (reverse-proxy to upstreams) could point me at the right way to configure it.

The current mod_pagespeed nginx:

  • Serves all SSL domains (https). Upstream reply from port 80.
  • handles all friendly urls for various backends (/friendly-url/ served by upstream1/script?param=friendly-url)
  • serves part of the static contect directly (/assets-dir/ is also mounted on this server so no need to go to the upstream for it)
  • also acts as the reverse proxy for 2 cdn and image server domains used in the html code served

So to clarify, from the proxy server point of view:

  • domain.com/friendly-url -> upstream1 /script?param=friendly-url)
  • domain.com/assets-dir/image.gif -> served directly by the proxy server as a location
  • cdn.domain.com/assets-dir/anotherimage.jpg -> served directly from the same nginx as another server with static content -> /assets-dir/anotherimage.jpg (cookieless nginx server)
  • image.domain.com/image.jpg -> upstream2/image.jpg (reverse proxy to another containers php server

Been so, for a long time our doubts on the correct setup are:

  1. should upstream1 (different container now also running nginx) also be running mod_pagespeed, would that benefit at all if mainly serving php files there?
  2. should mod_pagespeed also be activated on "cdn.domain.com" in the main reverse proxy, so it can be handled by "domain.com"? Can I do that (currently log full of: No permission to rewrite 'https://cdn.domain.com/asserts-dir/bootstrap.min.css'

I've been struggling to understand how to allow mod_pagespeed to rewrite also the content from our cdn served on another server of the same nginx. See: https://groups.google.com/g/mod-pagespeed-discuss/c/B5lLUa-GgsU

The (new) issues that come up are that the "friendly" urls are no longer available on the upstream, so not sure if pagespeed would handle that correctly.

Also had issues with extended_cache and source files updates: https://github.com/apache/incubator-pagespeed-ngx/issues/1626

luison avatar Jul 06 '22 12:07 luison