google字体无法使用怎么办 Nginx反代Google字体
2019/10/10/17:46:19 阅读:1858 来源:谷歌SEO算法 标签:
区块链
google在国内不能打开已经成了定局了,但google提供的很多服务还是蛮有用的,像google字体很多站长发现google打不开之后字体也无法使用了,下面我们就来看看google字体无法使问题的解决方法.
最近在写VPN系统的时候用到Google Fonts可是在大中国是无法使用Google字体,那么怎么解决呢?遂拿出AWS Japna节点反代Google字体一枚.
- upstreamgoogle{
- serverfonts.googleapis.com:80;
- }
- upstreamgstatic{
- serverfonts.gstatic.com:80;
- }
- server{
- listen80;
- listen[::]:80;
- server_namefonts.cxsir.com;
- location/css{
- sub_filter'fonts.gstatic.com''fonts.cxsir.com';
- sub_filter_onceoff;
- sub_filter_typestext/css;
- proxy_pass_headerServer;
- proxy_set_headerHostfonts.googleapis.com;
- proxy_set_headerAccept-Encoding'';
- proxy_redirectoff;
- proxy_set_headerX-Real-IP$remote_addr;
- proxy_set_headerX-Scheme$scheme;
- proxy_passhttp://google;
- }
- location/{
- proxy_pass_headerServer;
- proxy_set_headerHostfonts.gstatic.com;
- proxy_redirectoff;
- proxy_set_headerX-Real-IP$remote_addr;
- proxy_set_headerX-Scheme$scheme;
- proxy_passhttp://gstatic;
- }
- }
- #下面的是开启SSL需要的,如果你不需要SSL请不要复制下面的内容。
- server{
- listen443sslspdy;
- sslon;
- ssl_certificate/var/www/ssl/ssl.crt;
- ssl_certificate_key/var/www/ssl/ssl.key;
- ssl_session_timeout5m;
- ssl_protocolsTLSv1TLSv1.1TLSv1.2;
- ssl_prefer_server_cipherson;
- ssl_ciphersECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:RSA+3DES:!ADH:!AECDH:!MD5;
- server_namefonts.cxsir.com;
- location/css{
- sub_filter'http://fonts.gstatic.com''https://fonts.cxsir.com';
- sub_filter_onceoff;
- sub_filter_typestext/css;
- proxy_pass_headerServer;
- proxy_set_headerHostfonts.googleapis.com;
- proxy_set_headerAccept-Encoding'';
- proxy_redirectoff;
- proxy_set_headerX-Real-IP$remote_addr;
- proxy_set_headerX-Scheme$scheme;
- proxy_passhttp://google;
- }//phpfensi.com
- location/{
- proxy_pass_headerServer;
- proxy_set_headerHostfonts.gstatic.com;
- proxy_redirectoff;
- proxy_set_headerX-Real-IP$remote_addr;
- proxy_set_headerX-Scheme$scheme;
- proxy_passhttp://gstatic;
- }
- }
使用方法如果你是Ubuntu或者Debian那么你只需要执行apt-get install nginx就OK,CentOS自己百度,然后在path/nginx/conf.d/下新建一个conf文件,复制粘贴,替换文中的fonts.cxsir.com为你的域名,然后service nginx restart就OK了.
热门评论