Recently, when writing VPN system to use Google fonts but in the big China is unable to use Google fonts, then how to solve it? Then took out the AWS Japna node against Google font one.
Upstream Google {
Server fonts.googleapis.com:80;
}
Upstream Gstatic {
Server fonts.gstatic.com:80;
}
server {
Listen 80;
Listen [::]:80;
server_name fonts.cxsir.com;
LOCATION/CSS {
Sub_filter ' fonts.gstatic.com ' fonts.cxsir.com ';
Sub_filter_once off;
Sub_filter_types text/css;
Proxy_pass_header Server;
Proxy_set_header Host fonts.googleapis.com;
Proxy_set_header accept-encoding ';
Proxy_redirect off;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header X-scheme $scheme;
Proxy_pass Http://google;
}
Location/{
Proxy_pass_header Server;
Proxy_set_header Host fonts.gstatic.com;
Proxy_redirect off;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header X-scheme $scheme;
Proxy_pass http://gstatic;
}
}
#下面的是开启SSL需要的, if you do not need SSL, please do not copy the content below.
server {
Listen 443 SSL spdy;
SSL on;
SSL_CERTIFICATE/VAR/WWW/SSL/SSL.CRT;
Ssl_certificate_key/var/www/ssl/ssl.key;
Ssl_session_timeout 5m;
Ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
Ssl_prefer_server_ciphers on;
Ssl_ciphers ecdh+aesgcm:ecdh+aes256:ecdh+aes128:dh+3des:rsa+3des:! Adh:! aecdh:! MD5;
server_name fonts.cxsir.com;
LOCATION/CSS {
Sub_filter ' http://fonts.gstatic.com ' https://fonts.cxsir.com ';
Sub_filter_once off;
Sub_filter_types text/css;
Proxy_pass_header Server;
Proxy_set_header Host fonts.googleapis.com;
Proxy_set_header accept-encoding ';
Proxy_redirect off;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header X-scheme $scheme;
Proxy_pass Http://google;
}
Location/{
Proxy_pass_header Server;
Proxy_set_header Host fonts.gstatic.com;
Proxy_redirect off;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header X-scheme $scheme;
Proxy_pass http://gstatic;
}
}
How to use if you are Ubuntu or Debian then you only need to perform apt-get install Nginx Ok,centos yourself Baidu. Then under path/nginx/conf.d/a new conf file, copy paste, replace the text in the fonts.cxsir.com for your domain name. Then the service nginx restart is OK.