Google fonts do not use what to do nginx anti-generation Google fonts

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.