移动流媒体无法使用WAF + CloudFront + S3(在桌面浏览器上工作!)

时间:2016-04-20 14:41:18

标签: mobile amazon-s3 audio-streaming amazon-cloudfront soundmanager2

我在包含私有文件的S3存储空间上使用CloudFront Web分发流式传输文件(CloudFront可以访问它)。我使用AWS WAF验证请求是否来自我的域(带有referer标头),以避免使用其URL的简单复制粘贴直接下载音频文件。要播放音频文件,我使用SoundManager2。

问题:它就像桌面浏览器(Chrome,Firefox和Safari)上的魅力一样,但流媒体从未开始在移动设备上播放(在iOs和Android上测试过)。我不明白为什么。

**General**
Request URL:https://XXXXXXXXX.cloudfront.net/uploads/track/s3_file/XXXXX/XXXXXXXXXXXX.mp3
Request Method:GET
Status Code:206 Partial Content
Remote Address:XX.XX.XXX.X:XXX

**Response Headers**
Accept-Ranges:bytes
Age:9230
Cache-Control:max-age=31536000
Connection:keep-alive
Content-Length:2
Content-Range:bytes 0-1/4958188
Content-Type:audio/mp3
Date:Wed, 20 Apr 2016 11:35:09 GMT
ETag:"3f90ed8fa62501906107380830996ae9"
Last-Modified:Mon, 18 Apr 2016 15:05:16 GMT
Server:AmazonS3
Via:1.1 70801f007508df9ad04c63e7be99eab2.cloudfront.net (CloudFront)
X-Amz-Cf-Id:e-MSj2EuajyCKG8ah8f5WzjqQxymLfCeGaH5q6AMgt7T42u7wFKGig==
X-Cache:Hit from cloudfront

**Request Headers**
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Host:XXXXXXXXXX.cloudfront.net
Pragma:no-cache
Range:bytes=0-1
Referer:http://www.domain.com/this-is-a-playlist/other-lives-tamer-animals
Save-Data:on
User-Agent:Mozilla/5.0 (Linux; Android 5.1.1; A0001 Build/LMY48Y) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.105 Mobile Safari/537.36

在网络版上,SoundManager2发送第一个请求并取消它:

**General**
Request URL:https://XXXXXXXX.cloudfront.net/uploads/track/s3_file/XXX/XXXXXXXXXXXXX.mp3

**Request Headers**
Provisional headers are shown
Accept-Encoding:identity;q=1, *;q=0
Range:bytes=0-
Referer:http://www.domain.com/this-is-a-playlist/other-lives-tamer-animals
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36

然后这个请求就在上面之后:

**General**
Request URL:https://XXXXXXXXXXX.cloudfront.net/uploads/track/s3_file/XXX/XXXXXXXXXX.mp3
Request Method:GET
Status Code:206 Partial Content
Remote Address:XX.XX.XXX.XXX:XXX

**Response Headers**
view source
Accept-Ranges:bytes
Age:168539
Cache-Control:max-age=31536000
Connection:keep-alive
Content-Length:4958188
Content-Range:bytes 0-4958187/4958188
Content-Type:audio/mp3
Date:Mon, 18 Apr 2016 15:35:12 GMT
ETag:"3f90ed8fa62501906107380830996ae9"
Last-Modified:Mon, 18 Apr 2016 15:05:16 GMT
Server:AmazonS3
Via:1.1 c035b03e455c334ee837503784ad41c8.cloudfront.net (CloudFront)
X-Amz-Cf-Id:bE3BNkkvWJ08qwcsRT-3TIvHs6dXT-QIJ8UP6kl3vQVg89LaiO1Npg==
X-Cache:Hit from cloudfront

**Request Headers**
view source
Accept:*/*
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:fr,en-US;q=0.8,en;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Host:XXXXXXXXXXX.cloudfront.net
Pragma:no-cache
Range:bytes=0-
Referer:http://www.domain.com/this-is-a-playlist/other-lives-tamer-animals
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36

在移动设备上,SoundManager2在日志中达到playing状态,但现在播放音乐。有人知道为什么流不能在移动设备上启动???

1 个答案:

答案 0 :(得分:0)

在Windows Mobile上,这可以工作 在此处查看有关某些移动浏览器上有关WAF和HTML5音频/视频的说明:
Preventing Amazon Cloudfront hotlinking