Skip to content

Instantly share code, notes, and snippets.

@caiguanhao
Last active August 29, 2015 14:07
Show Gist options
  • Save caiguanhao/6a896cb92bfc8fb03a84 to your computer and use it in GitHub Desktop.
Save caiguanhao/6a896cb92bfc8fb03a84 to your computer and use it in GitHub Desktop.
twitter proxy (but lacks a filter to replace cookie response header, so can't log in)
server {
listen 443;
server_name t.cgh.io;
subs_filter_types text/html text/css text/javascript application/javascript;
subs_filter "(https:)?//([^.]+?)\.twimg\.com/" "//t.cgh.io/__twimg/$2/" r;
subs_filter "(https:)?//twitter\.com/" "//t.cgh.io/" r;
subs_filter "\"twitter.com\"" "\"t.cgh.io\"";
location ~ /__twimg/([^/]+)/ {
resolver 8.8.8.8;
proxy_pass https://$1.twimg.com;
proxy_set_header Accept-Encoding "";
rewrite /__twimg/([^/]+)/(.*) /$2 break;
}
location / {
proxy_pass https://twitter.com;
proxy_set_header Accept-Encoding "";
proxy_hide_header content-security-policy;
proxy_hide_header content-security-policy-report-only;
proxy_cookie_domain twitter.com t.cgh.io;
}
}
server {
server_name y.cgh.io;
subs_filter_types text/html text/css text/javascript application/json;
subs_filter "(https:)?\\\/\\\/([^/]+?)\.doubleclick\.net" "\/\/y.cgh.io\/__dc\/$2\/" r;
subs_filter "(https:)?//([^/]+?)\.ggpht.com/" "//y.cgh.io/__ggpht/$2/" r;
subs_filter "(https:)?//([^/]+?)\.ytimg\.com/" "//y.cgh.io/__ytimg/$2/" r;
subs_filter "(https:)?\\\/\\\/([^/]+?)\.ytimg\.com\\\/" "\/\/y.cgh.io\/__ytimg\/$2\/" r;
subs_filter "https:\\\/\\\/([^/]+?)\.googlevideo\.com" "\/\/y.cgh.io\/__googlevideo\/$1" r;
subs_filter "(https%3A)?%2F%2F([^F]+?)\.googlevideo\.com%2F" "%2F%2Fy.cgh.io%2F__googlevideo%2F$2%2F" r;
#subs_filter "s.youtube.com" "y.cgh.io/__youtube/s";
#subs_filter "s.ytimg.com" "y.cgh.io/__ytimg/s";
location ~ /__dc/([^/]+?)/(.*) {
resolver 8.8.8.8;
proxy_pass https://$1.doubleclick.net;
rewrite /__dc/([^/]+?)/(.*) /$2 break;
}
location ~ /__ggpht/([^/]+?)/(.*) {
resolver 8.8.8.8;
proxy_pass https://$1.ggpht.com;
rewrite /__ggpht/([^/]+?)/(.*) /$2 break;
}
location ~ /__youtube/([^/]+?)/(.*) {
resolver 8.8.8.8;
proxy_pass https://$1.youtube.com;
rewrite /__youtube/([^/]+?)/(.*) /$2 break;
}
location ~ /__googlevideo/([^/]+?)/(.*) {
resolver 8.8.8.8;
proxy_pass https://$1.googlevideo.com;
rewrite /__googlevideo/([^/]+?)/(.*) /$2 break;
}
location ~ /__ytimg/([^/]+?)/(.*) {
resolver 8.8.8.8;
proxy_pass https://$1.ytimg.com;
proxy_set_header Accept-Encoding "";
rewrite /__ytimg/([^/]+)/(.*) /$2 break;
}
location / {
proxy_pass https://m.youtube.com;
proxy_set_header Accept-Encoding "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment