Skip to content

Instantly share code, notes, and snippets.

@chengyuhui
Last active March 25, 2017 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chengyuhui/da2ba856fa4ee09aebd1833241459a72 to your computer and use it in GitHub Desktop.
Save chengyuhui/da2ba856fa4ee09aebd1833241459a72 to your computer and use it in GitHub Desktop.
upstream soundcloud_main {
server 54.192.9.210:443;
server 54.192.27.193:443;
server 54.192.27.35:443;
server 54.192.27.27:443;
server 54.192.27.133:443;
server 54.192.27.150:443;
server 54.192.27.212:443;
}
proxy_cache_path /var/cache/soundcloud_proxy/ levels=1:2 keys_zone=soundcloud_cache:10m max_size=100m inactive=60m use_temp_path=off;
server {
listen 2333;
server_name _;
set $proxy_path sc.thwiki.cc;
gzip on;
location ~ /api.soundcloud.com/api.soundcloud.com/(?<real_path>(.*)) {
rewrite .* http://$proxy_path/api.soundcloud.com/$real_path break;
}
location ~ ^/(?<orig_host>(.+?)).soundcloud.com/ {
rewrite /(.+?)/(.*) /$2 break;
if ($orig_host = "api") {
set $cache 1;
}
proxy_cache_bypass $cache;
proxy_no_cache $cache;
proxy_cache soundcloud_cache;
proxy_pass https://soundcloud_main;
proxy_set_header Host $orig_host.soundcloud.com;
proxy_set_header X-Forwarded-Host "";
proxy_ssl_server_name on;
proxy_ssl_name $orig_host.soundcloud.com;
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types application/javascript;
sub_filter https://w.soundcloud.com http://$proxy_path/w.soundcloud.com;
sub_filter https://api.soundcloud.com http://$proxy_path/api.soundcloud.com;
sub_filter src="/player/ src="http://$proxy_path/w.soundcloud.com/player/;
sub_filter scheme:"https" scheme:"http";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment