In Nginx proxy for Google URLs in WordPress, I wrote lots of lines configuring proxies and subs_filter rules.
Here is the newer simplified one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
proxy_cache_path /dev/shm/ncache keys_zone=cache_zone:10m; ... server{ ... location ~ ^/p/(?<p_domain>[a-z0-9A-Z\.\-]+)/(?<p_ext>.+)$ { rewrite ^/p/([a-z0-9A-Z\.\-]+)/(.+)$ /$2 break; proxy_pass http://$p_domain:80; proxy_set_header Host $p_domain; proxy_set_header Accept-Encoding ""; proxy_cache cache_zone; proxy_cache_valid 200 302 10m; } subs_filter_types text/html* text/css application/javascript; subs_filter (\'|\"|url\()(https:|http:|)//(fonts.googleapis.com|themes.googleusercontent.com|apis.google.com) $1/p/$3 gr; } |
Updated(2014-09-19):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
location ~ ^/p/(?<p_domain>[a-z0-9A-Z\.\-]+)/(?<p_ext>.+)$ { rewrite ^/p/([a-z0-9A-Z\.\-]+)/(.+)$ /$2 break; proxy_pass http://$p_domain:80; proxy_set_header Host $p_domain; proxy_set_header Accept-Encoding ""; proxy_buffer_size 64k; proxy_buffers 32 32k; proxy_busy_buffers_size 128k; proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_user_agent$http_accept_language$http_accept"; proxy_cache cache_zone; proxy_cache_valid 200 302 10m; expires 5m; } subs_filter_types text/html* text/css application/javascript application/x-javascript; subs_filter (\'|\"|url\()(https:|http:|)//(fonts.googleapis.com|themes.googleusercontent.com|apis.google.com|fonts.gstatic.com) $1/p/$3 gr; subs_filter (\'|\"|url\()(https:|http:|)//(s7.addthis.com|ct1.addthis.com|m.addthis.com|q.addthis.com) $1/p/$3 gr; |
Incoming search terms: