2013-07-22 7 views
5

AWS S3のherokuでWebフォント(特にfontawesome)をdjangoプロジェクトにホストして提供しようとしていますが、恐怖を克服するのが難しいです。firefox cross-domain font-loading issue私はすべての文書化された、受け入れられた解決策を試してきましたが、私のために働いているものはありません。私はこれらの設定のさまざまなバリエーションを試してみたとFirefoxは、まだ私にhttps://www.myapp.comから禁じられHTTP 403を与えているFirefox WebFont 403 S3 CORSルールにもかかわらず

<?xml version="1.0" encoding="UTF-8"?> 
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
    <CORSRule> 
     <AllowedOrigin>https://myapp.herokuapp.com</AllowedOrigin> 
     <AllowedOrigin>https://www.myapp.herokuapp.com</AllowedOrigin> 
     <AllowedOrigin>https://myapp.com</AllowedOrigin> 
     <AllowedOrigin>https://www.myapp.com</AllowedOrigin> 
     <AllowedMethod>GET</AllowedMethod> 
     <MaxAgeSeconds>3000</MaxAgeSeconds> 
     <AllowedHeader>Authorization</AllowedHeader> 
    </CORSRule> 
</CORSConfiguration> 

私が見ておく推奨されるソリューションは、私のS3バケットにCORSのコンフィグを編集することです

Request URL: https://my_bucket.s3.amazonaws.com/css/fontawesome-webfont-webfont.ttf 
Request Method: GET 
Status Code: HTTP/1.1 403 Forbidden 

このHTTPリクエストでは、応答ヘッダーに「Access-Control-Allow-Credentials:true」と表示されます。

S3からフォントを受け入れるためにfirefoxに宣言する必要がある別のCORS規則がありますか?

> https://s3.amazonaws.com/my_bucket/font/fontawesome-webfont.eot 
* About to connect() to s3.amazonaws.com port 443 (#0) 
* Trying xxx.xx.xx.xxxx... connected 
* Connected to s3.amazonaws.com (xxx.xx.xx.xxx) port 443 (#0) 
* SSLv3, TLS handshake, Client hello (1): 
* SSLv3, TLS handshake, Server hello (2): 
* SSLv3, TLS handshake, CERT (11): 
* SSLv3, TLS handshake, Server finished (14): 
* SSLv3, TLS handshake, Client key exchange (16): 
* SSLv3, TLS change cipher, Client hello (1): 
* SSLv3, TLS handshake, Finished (20): 
* SSLv3, TLS change cipher, Client hello (1): 
* SSLv3, TLS handshake, Finished (20): 
* SSL connection using DES-CBC3-SHA 
* Server certificate: 
*  subject: C=US; ST=Washington; L=Seattle; O=Amazon.com Inc.; CN=s3.amazonaws.com 
*  start date: 2010-10-08 00:00:00 GMT 
*  expire date: 2013-10-07 23:59:59 GMT 
*   common name: s3.amazonaws.com (matched) 
*  issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of use at https://www.verisign.com/rpa (c)09; CN=VeriSign Class 3 Secure Server CA - G2 
*  SSL certificate verify ok. 
> GET /my_bucket/font/fontawesome-webfont.eot HTTP/1.1 
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5 
> Host: s3.amazonaws.com 
> Accept: */* 
> Origin: https://www.myapp.com 
> 
< HTTP/1.1 200 OK 
< x-amz-id-2: XxMCWhqMsTGMMmAQnSHT/+RO7aluQSRyZ5wTAseMKM5cpavE+NkBQCuD8ykiIIDE 
< x-amz-request-id: 90FF2C1C85254815 
< Date: Mon, 22 Jul 2013 01:54:53 GMT 
< Access-Control-Allow-Origin: https://www.myapp.com 
< Access-Control-Allow-Methods: GET 
< Access-Control-Max-Age: 3000 
< Access-Control-Allow-Credentials: true 
< Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method 
< Last-Modified: Mon, 22 Jul 2013 01:44:31 GMT 
< ETag: "455808250694e5760bd92b3ce1f070b6" 
< Accept-Ranges: bytes 
< Content-Type: application/octet-stream 
< Content-Length: 25395 
< Server: AmazonS3 
< 
3cOb?LP&?S~FontAwesomeRegular"Version 1.00 2012&FontAwesome RegularBSGPɴbGbKV?????Y?D 

は、この作業を取得する可能性がありますアクセス制御 - 許可 - 起源を設定する別の方法があります:私は、フォント素晴らしい、私は得ることはありませんがカールする場合/これをトラブルシューティングに役立つ何かを参照してください?

+1

私は同じ問題を抱えていて、あなたが回避策を見つけたのか不思議です。 – Zane

+0

あなたの設定はOKです。 2つの例では、URLが同じではないことを示しています。正しいファイル名を要求していますか? – qff

答えて

1

バケットポリシーで特定のHTTP参照元へのアクセスを制限する場合は、バケットURLをリファラーリストにも追加します。例:

"Condition": { 
    "StringLike": { 
     "aws:Referer": [ 
      "http://my_bucket.s3.amazonaws.com/*", 
      "https://my_bucket.s3.amazonaws.com/*", 
      "http://www.example.com/*", 
      "https://www.example.com/*", 
     ] 
    } 
} 

Firefoxの応答ヘッダーを確認してください。あなたのドメインではなく、s3バケットでホストされているあなたのCSSファイルが、フォントのrefererであることが分かります。

関連する問題