简直 Exciting!
还有为什么部分 css 不能被替换,已经在后端禁用 gzip 了
location /fonts {
proxy_pass https://fonts.googleapis.com/;
proxy_redirect off;
proxy_set_header Accept-Encoding '';
subs_filter_types text/css text/xml application/x-javascript;
sub_filter_once off;
subs_filter fonts.gstatic.com cdn.moefont.com/gstatic;
}
更加奇怪的是部分能替换,部分不能
如 https://cdn.moefont.com/fonts/earlyaccess/notosanssc.css 可以
https://cdn.moefont.com/fonts/css?family=Source+Sans+Pro 这个就不行
1
ZGLHHH 2016-03-26 20:19:52 +08:00
|
2
VmuTargh 2016-03-26 20:20:22 +08:00 via Android 1
你应该说: 简直 Excited! 这才是正确读法←_←
|
3
kn007 2016-03-26 20:21:02 +08:00
我这边都有被替换。
chrome 。或许你那边 cache 了? |
7
kn007 2016-03-26 20:58:39 +08:00
@Andy1999 就是就是,我觉得会不会你挂 VPN 的原因,解析的 CDN 服务器上的内存 cache 的不对?
你那几台服务器或许需要集体 clean 下,或者对现在错的 ip 所属 clean 。。 |
9
aofall 2016-03-26 21:07:58 +08:00
访问的地址是可以根据浏览器来判断、加载不同 css 以加载不同格式的字体
https://fonts.googleapis.com/css?family=Kavoon 用 Chrome 访问返回 woff2 格式的字体 IE 访问返回 woff 格式的字体 etc. |
12
VmuTargh 2016-03-26 22:40:29 +08:00
noysk_000@WINDOWS-QU992AO MINGW32 ~
$ curl -v https://cdn.moefont.com/fonts/css?family=Source+Sans+Pro * STATE: INIT => CONNECT handle 0x200482f0; line 1103 (connection #-5000) * Added connection 0. The cache now contains 1 members * Trying 119.147.33.20... * STATE: CONNECT => WAITCONNECT handle 0x200482f0; line 1156 (connection #0) * Connected to cdn.moefont.com (119.147.33.20) port 443 (#0) * STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x200482f0; line 1253 (connection #0) * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /usr/ssl/certs/ca-bundle.crt CApath: none * TLSv1.2 (OUT), TLS header, Certificate Status (22): * TLSv1.2 (OUT), TLS handshake, Client hello (1): * STATE: SENDPROTOCONNECT => PROTOCONNECT handle 0x200482f0; line 1267 (connection #0) * TLSv1.2 (IN), TLS handshake, Server hello (2): * NPN, negotiated HTTP1.1 * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Client hello (1): * TLSv1.2 (OUT), TLS handshake, Unknown (67): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Client hello (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / AES256-GCM-SHA384 * ALPN, server did not agree to a protocol * Server certificate: * subject: OU=Domain Control Validated; CN=*.moefont.com * start date: Sep 29 14:43:18 2015 GMT * expire date: Sep 29 14:43:18 2016 GMT * subjectAltName: cdn.moefont.com matched * issuer: C=BE; O=GlobalSign nv-sa; CN=AlphaSSL CA - SHA256 - G2 * SSL certificate verify ok. * STATE: PROTOCONNECT => DO handle 0x200482f0; line 1288 (connection #0) > GET /fonts/css?family=Source+Sans+Pro HTTP/1.1 > Host: cdn.moefont.com > User-Agent: curl/7.47.1 > Accept: */* > * STATE: DO => DO_DONE handle 0x200482f0; line 1350 (connection #0) * STATE: DO_DONE => WAITPERFORM handle 0x200482f0; line 1477 (connection #0) * STATE: WAITPERFORM => PERFORM handle 0x200482f0; line 1487 (connection #0) * HTTP 1.1 or later with persistent connection, pipelining supported < HTTP/1.1 200 OK * Server nnws/1.7.3.6 is not blacklisted < Server: nnws/1.7.3.6 < Date: Sat, 26 Mar 2016 14:27:38 GMT < Content-Type: text/css; charset=utf-8 < Content-Length: 274 < Connection: keep-alive < Cache-Control: private, max-age=86400 < Expires: Sun, 27 Mar 2016 14:27:38 GMT < Content-Encoding: identity < Access-Control-Allow-Origin: * < Timing-Allow-Origin: * < X-Content-Type-Options: nosniff < X-Frame-Options: SAMEORIGIN < X-XSS-Protection: 1; mode=block < Alternate-Protocol: 443:quic,p=1 < Alt-Svc: quic=":443"; ma=2592000; v="31,30,29,28,27,26,25" < X-Daa-Tunnel: hop_count=1 < @font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 400; src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url( https://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlNzbP97U9sKh0jjxbPbfOKg.ttf) format('truetype'); } * STATE: PERFORM => DONE handle 0x200482f0; line 1645 (connection #0) * Curl_done * Connection #0 to host cdn.moefont.com left intact Vivaldi 1.0.430.3: Firefox 43.0: Firefox 43.0 with Chrome UA: Firefox 43.0 with Edge UA: Firefox 43.0 with iPhone3.0 UA: Firefox 43.0 with Safari UA: |
13
VmuTargh 2016-03-26 22:42:28 +08:00
空 UA:
@font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 400; src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url( https://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlNzbP97U9sKh0jjxbPbfOKg.ttf) format('truetype'); } |
14
Andy1999 OP |
16
konakona 2016-03-26 22:53:15 +08:00
哼,可恶,为什么你屏幕那么大!
|
17
VmuTargh 2016-03-26 23:01:57 +08:00
@Andy1999 http://diylighttpd-vtkg.rhcloud.com/gfonts/css?family=Source+Sans+Pro
你丫参数写错了吧 报错信息: nginx: [emerg] unknown directive "subs_filter" in /var/lib/openshift/xx/app-root/data//nginx/conf/nginx.conf:57 An error occurred executing 'gear start' (exit code: 1) Error message: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/xx/diy |
18
VmuTargh 2016-03-26 23:05:42 +08:00
@Andy1999 Reset 的话用这个: https://etula.me/gfonts/css?family=Source+Sans+Pro
|
19
Andy1999 OP @VmuTargh 这需要额外的模块啊…
你是怎么替换的 但是如果不用这个,用 Nginx 默认的替换模块只能替换一次 |
22
indust 2016-03-26 23:42:46 +08:00 1
@VmuTargh
subs_filter 是这个第三方模块的命令 https://github.com/yaoweibin/ngx_http_substitutions_filter_module sub_filter 才是官方 http_sub_module 模块的 |
25
VmuTargh 2016-03-27 12:49:18 +08:00
|
26
indust 2016-03-27 15:37:56 +08:00 1
有些文件不会被替换应该是这个第三方模块的问题 https://github.com/yaoweibin/ngx_http_substitutions_filter_module/blob/master/ngx_http_subs_filter_module.c#L248
如果响应头里 Content-Encoding 是 identity 的话就会被当成压缩内容不作处理 官方的模块没有这个问题, 但只是字符替换的话局限性太大 |
27
VmuTargh 2016-03-27 16:58:41 +08:00
|
28
VmuTargh 2016-03-27 16:59:40 +08:00
|
29
Andy1999 OP |