How do I Properly Use Pagespeed Module with a Proxy Server?

1,188 views
Skip to first unread message

Saul Fontenot-Amedee

unread,
Aug 5, 2017, 10:44:33 AM8/5/17
to mod-pagespeed-discuss
Hi I have a Nginx proxy server that is also running mod-pagespeed. It looks like this-

Site requests -> Proxy Server at location 1 -> Makes Request to Server at location 2

Basically I am getting a log filled with no permission to rewrite errors. Everything is trying to run but cannot save even though the /var/www/filecache/ folder has correct permissions for the pagespeed module to write to.

---------------------------in nginx.conf----------------

#pagespeed settings
        pagespeed FileCachePath  "/var/www/filecache/";
        pagespeed CacheFragment some_token;
        pagespeed ServeRewrittenWebpUrlsToAnyAgent off;
        include /etc/nginx/sites-enabled/*;
        include /etc/nginx/conf.d/*.conf;
        pagespeed EnableFilters in_place_optimize_for_browser;
        pagespeed FetchWithGzip on;
        pagespeed EnableFilters defer_javascript;
        pagespeed UseExperimentalJsMinifier on;
        pagespeed EnableFilters flatten_css_imports,combine_css,prioritize_critical_css,combine_css,inline_google_font_css,rewrite_css,inline_css,rewrite_style_attributes_with_url;
        pagespeed EnableFilters defer_javascript,rewrite_javascript,inline_javascript;
        pagespeed EnableFilters convert_jpeg_to_progressive,inline_images,resize_images,recompress_png,recompress_jpeg,convert_jpeg_to_progressive,rewrite_images,sprite_images,resize_rendered_image_dimensions,lazyload_images;
        pagespeed RespectVary on;
        pagespeed EnableFilters extend_cache;
        pagespeed ForceCaching on;

-------------in the sitespecfic conf-----------

       server {
        listen *:80;
        listen *:443 ssl;
        ssl on;
        server_name sitename sitename;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate/path-to-site-ssl/sitename.crt;
        ssl_certificate_key /path-to-site-ssl/sitename.key;

        access_log /var/www/sitename/log/access.log main;
        error_log  /var/www/sitename/log/error.log info;
        include    /etc/nginx/rewrite_rules/sitename;
    location / {
        proxy_pass http://second-ip-address:80
        include /etc/nginx/proxy.conf;
        sub_filter_types *;
        sub_filter 'http://' 'https://';
        sub_filter_once off;
    } # end / location
        location /cms/ {
                pagespeed off;
                proxy_pass https://second-ip-address:443;
                include /etc/nginx/proxy.conf;
                pagespeed RespectVary on;
        }
        location /jsapi/ {
                pagespeed off;
                proxy_pass https://second-ip-address:443;
                include /etc/nginx/proxy.conf;
                pagespeed RespectVary on;
        }
}

-----------------/etc/nginx/proxy.conf--------------------

proxy_redirect off;
proxy_ssl_session_reuse off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header    X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;


------------example error output----------------

2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'
2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No permission to rewrite 'http://img.level8ds.com/mls/13133/71-hickory-hill-ln-oxford-maine-mls1313310-img00-thumb.jpg'

-------------------------------

Any help would be greatly appreciated. 

thanks!

Luke Kenneth Casson Leighton

unread,
Aug 5, 2017, 12:37:00 PM8/5/17
to mod-pagesp...@googlegroups.com
On Sat, Aug 5, 2017 at 3:44 PM, Saul Fontenot-Amedee
<sa...@greenseedsdesign.com> wrote:

> 2017/08/05 14:34:40 [info] 26570#26580: [ngx_pagespeed 1.12.34.2-0] No
> permission to rewrite
> 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic'

https://github.com/pagespeed/mod_pagespeed/issues/596

hi saul check the bits about setting the domain.

l.

Joshua Marantz

unread,
Aug 5, 2017, 1:19:40 PM8/5/17
to mod-pagespeed-discuss
Actually the module is working as intended, based on your email.  If I understand correctly, you are using NPS as a reverse-proxy optimizer for an origin site that references external libraries from Google.  That's fine -- you are not reverse-proxying Google so you can't rewrite the content.  It's saying "no permission" but really it just means "that won't work".  And you shouldn't need to; the Google content is already optimized.

These are Info messages and wouldn't be in your logs at all when you set your loglevel to warning or error.

You *can* improve the font-loading path with https://modpagespeed.com/doc/filter-css-inline-google-fonts

You can also proxy the Google content by rewriting URLs to it, but I don't recommend it.  See https://modpagespeed.com/doc/domains#MapProxyDomain for details.



--
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/CAPweEDxXC2VwrNO3DnOz5JbF5Xxi%2BQWZ%3DODzYqfaadZstmb4Tw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Saul Fontenot-Amedee

unread,
Aug 7, 2017, 11:36:48 AM8/7/17
to mod-pagespeed-discuss
Thanks for the input. I had a bunch of issues to work out with pagespeed before I can really use it on a proxy server. I will keep trying for now I disabled it on this site I am working on. Maybe I can contribute a blog somewhere. Maybe I can find a good post somewhere. Overall there is not a lot of information about how to do this well. I guess that is ok but I am trying to build an application that would utilize pagespeed and nginx. At this point I am not very confident that it will work the way I think it should. 

Joshua Marantz

unread,
Aug 7, 2017, 11:41:15 AM8/7/17
to mod-pagespeed-discuss
OK Saul.  Is there something specific about your model of how it should work that you can describe?   There's nothing in your response to address really :)

RE 'not a lot of information': searching in this forum or on Stack Overflow, or even your favorite search engine, might be a good start.  There are plenty of blog posts about it from various sources.  One of my favorites (about proxies, but probably not for your application): https://00f.net/2012/06/02/mod-pagespeed-as-a-proxy-for-your-phone/

--
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.
Reply all
Reply to author
Forward
0 new messages