google在国内不能打开已经成了定局了,但google提供的很多服务还是蛮有用的,像google字体很多站长发现google打不开之后字体也无法使用了,下面我们就来看看google字体无法使问题的解决方法.
最近在写VPN系统的时候用到Google Fonts可是在大中国是无法使用Google字体,那么怎么解决呢?遂拿出AWS Japna节点反代Google字体一枚.
- 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需要的,如果你不需要SSL请不要复制下面的内容。
- 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;
- } //Vevb.com
- 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;
- }
- }
使用方法如果你是Ubuntu或者Debian那么你只需要执行apt-get install nginx就OK,CentOS自己百度,然后在path/nginx/conf.d/下新建一个conf文件,复制粘贴,替换文中的fonts.cxsir.com为你的域名,然后service nginx restart就OK了.
新闻热点
疑难解答