The Journey of a Network Engineer

Dec 24 2011   12:18AM GMT

How to configure ProxySG to cache youtube video?



Posted by: Sulaiman Syed
Tags:
BlueCoat
cache
googlevideo
proxy
proxysg
video
youtube

Many medium to big organizations use ProxySG to filter and control the traffic leaving the enterprise network. One of the big strengths of Bluecoat ProxySG is the cache. It is one of the best cache devices out there in the market.

As we all know, youtube can be considered one of the main web applications that eat up the bandwidth. The content is very dynamic, and the url’s are ever changing. one of the main issues with youtube videos that they are served from various mirroring websites. Thus, proxySG can’t cache the videos by default since the URL are different for the same data. I have came across a policy that can be added to ProxySG. This will enable youtube caching!

<Proxy “YouTube specific caching rewrite”> condition=youtube_related_request
condition=youtube_seek_video_requests ; leave seek requests alone, not caching
condition=youtube_video_request_style1 url.query.regex=”itag=34″ action.rename_youtubeSD(yes)
condition=youtube_video_request_style2 url.query.regex=”itag=34″ action.rename_youtube_style2SD(yes)
condition=youtube_video_request_style1 action.rename_youtube(yes)
condition=youtube_video_request_style2 action.rename_youtube_style2(yes)
condition=youtube_host_patterns condition=youtube_video_requests action.rename_youtube_url_hostname(yes)
<Cache “video content”>

; YOUTUBE & GOOGLEVIDEO – 10 days
[rule]
condition=youtube_seek_video_requests cache(no)
condition=youtube_video_requests ttl(864000) force_cache(all)

; YOUTUBE DEFINITIONS
;
define condition youtube_related_request
request.header.Referer.exists=yes condition=youtube_referer_present
condition=youtube_host_patterns
end

define condition youtube_host_patterns
url.host.substring=”youtube”
url.host.substring=”googlevideo”
url.host.is_numeric=yes url.address=youtube_subnets
end

define subnet youtube_subnets
;; these can be fairly broadly drawn, since appearance in here
;; alone does not itself force youtubeization; the request also
;; has to be relatively youtube specific.
;; IE this is an optimization, not a pure correctness filter
; observed in eval logs Mar2010

74.125.0.0/16    ; GOOGLE NET-74-125-0-0-1
173.194.0.0/16   ; GOOGLE NET-173-194-0-0-1
;204.246.234.23/24 ; used by cache but assigned to frontiernet.net
;youtube_ARIN_IPs
;IPv4 CIDR:
208.65.152.0/22  ; YOUTUBE
64.15.112.0/20   ; YOUTUBE2
208.117.224.0/19 ; YOUTUBE3
72.51.34.221/32
72.51.34.222/31
72.51.34.224/29
72.51.34.232/30
72.51.34.236/32
72.51.35.205/32
72.51.35.206/31
72.51.35.208/30
72.51.35.212/32
; 75.35.233.64/29   ; now sbcglobal
; 75.31.180.240/29  ; now sbcglobal
76.210.160.216/29
76.208.211.160/29
; 75.48.116.72/29   ; now sbcglobal
75.55.218.8/29
;IPv6 CIDR:
;2620:0000:0040:0000:0000:0000:0000:0000/48
;
;youtube_RIPE_IPs
;IPv4 CIDR:
194.221.68.0/24
195.27.182.0/24
195.59.171.0/24
213.146.171.0/24
82.129.37.0/24     ; YOUTUBE-EUROPE
89.207.225.0/24
209.85.128.0/17    ; Seen at Mobily
end

define condition youtube_referer_present
request.header.Referer.url.substring=”ytimg”
request.header.Referer.url.substring=”youtube”
request.header.Referer.url.substring=”video.google.com”
end

define condition youtube_video_request_style1
url.path.exact=”/get_video” url.query.regex=”video_id=”
end

define condition youtube_video_request_style2
url.path.exact=”/videoplayback” url.query.regex=”id=”
end

define condition youtube_video_requests
condition=youtube_video_request_style1
condition=youtube_video_request_style2
end

define condition youtube_seek_video_requests
url.path.exact=/videoplayback url.query.regex=”begin=[1-9]”
url.path.exact=/get_video url.query.regex=”begin=[1-9]”
end

define action rename_youtube
;–NOTE the following is one line (approximately 120 characters long)
rewrite(url, “(.+)video_id=([^&]+)(\&.*|$)”, “http://youtube.proxysg-cache/get_video/$(2)”, cache)
end

define action rename_youtube_style2
;–NOTE the following is one line (approximately 120 characters long)
rewrite(url, “(.+)id=([^&]+)(\&.*|$)”, “http://youtube.proxysg-cache/get_video_style2/$(2)”, cache)
end

define action rename_youtubeSD
;–NOTE the following is one line (approximately 120 characters long)
rewrite(url, “(.+)video_id=([^&]+)(\&.*|$)”, “http://youtube.proxysg-cache/get_video/$(2)_SD”, cache)
end

define action rename_youtube_style2SD
;–NOTE the following is one line (approximately 120 characters long)
rewrite(url, “(.+)id=([^&]+)(\&.*|$)”, “http://youtube.proxysg-cache/get_video_style2/$(2)_SD”, cache)
end

define action rename_youtube_url_hostname
rewrite(url.host, “.*”, “youtube.proxysg-cache”, cache)
end

This policy was not written by me. but of course it can be used by any ProxySG administrator. Please just copy paste it into the local policy files.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: