Nginx proxy for Google URLs in WordPress

I wrote a script how to make fonts.googleapis.com not bring down the load speed of WordPress for visitors from China.
Here is the link: Google Font Api Proxy for WordPress
To use this proxy, I have to edit themes’ files even the script-loader.php by WordPress, that’s a disaster for upgrading.

Another problem is, I have SSL enabled on my blog. Every time I visit my blog, Chrome notices me that

The page at ‘https://sskaje.me/’ was loaded over HTTPS, but displayed insecure content from ‘/p/themes.googleusercontent.com/static/fonts/opensans/v6/xxxxxxxx.woff’: this content should also be loaded over HTTPS.

The SSL green lock icon in the address bar is always be ‘warned’.

The new solution is using nginx’s substitution modules.
My blog is running on a Ubuntu 13.10, nginx 1.41, config options are below:

At the very beginning, I tried ‘ngx_http_sub_module‘, but only one sub_filter can be used in each directive, and regexp is not supported.

Then comes ngx_http_substitutions_filter_module, another nginx module and a better choice.

First, set up two proxy location for fonts.googleapis.com and themes.googleusercontent.com, turn off Accept-Encoding to disable compression.
Then, set subs_filter_types to support text/css.
At last, write regex substitutions, with gr flags on.

Following configurations are added to the end of my server{} directive.

UPDATE[2014-01-12]:
If you have cache plugin like ‘WP Super Cache’, make sure you have turned compression off in the plugin setting pages.
For ‘WP Super Cache’, setting locates at Settings->WP Super Cache Settings->Advanced->Compress pages so they’re served more quickly to visitors. (Recommended).

You can enable compression from your http server, e.g. nginx, apache httpd.

Nginx proxy for Google URLs in WordPress by @sskaje: https://sskaje.me/2014/01/nginx-proxy-google-urls-wordpress/