Contents

Build a Proxy Server to Access Chinese IP Including Netease Music


Sometimes we need to access Chinese content, like Youku Video, Netease Music (Cloud Music) and QQ music. It is very annoying to get “Can Only Be Streamed in Mainland China” or similar messages. Being tired of that, fortunately I have got a VPS from Aliyun and I build a proxy server using Shadowsocks on it and everything works smoothly now.

VPS

You need to have a VPS with Chinese IP address, there are tons of choices, like Aliyun(Alibaba Cloud) and Tencent Cloud etc.

Install Server

Then ssh to your cloud server or any other tools to get into your server and install Shadowsocks, you can follow the instruction here. I use the Python version.

Config Shadowsocks

Config Shadowsocks, I usually write my configuration file in /etc/shadowsocks/ss.json. Please NOTE that the server attribute in most of the case should be your VPS’ public IP address. However, AFAIK, for Aliyun and AWS, it will not work if you do so (Error message socket.error: [Errno 99] Cannot assign requested address will pop up when you try to run it). The reason is the public IP address is not the “actual” IP when it is used to bind IP and port to the VPS machine, it may refer to other VPS in the local network. Therefore, 0.0.0.0 to listen to all the IP addresses should be used.

1
2
3
4
5
6
7
8
{
	"server":"0.0.0.0",
	"server_port":8080,
	"local_port":1080,
	"password":"yourpassword",
	"timeout":600,
	"method":"chacha20"
}

Optional

Install m2crypto to make encryption a little bit faster.

1
pip install m2crypto

If you want to use chacha20 as encryption method, libsodium must be installed. Otherwise, you could use aes-256-cfb.

1
2
3
4
5
wget https://github.com/jedisct1/libsodium/releases/download/1.0.16/libsodium-1.0.16.tar.gz
tar -xf libsodium-1.0.16.tar.gz && cd libsodium-1.0.16
./configure && make -j2 && make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

Run

Run the server as daemon!

1
ssserver -c /etc/shadowsocks/ss.json -d start

Alternatively, you can run the server at the front for debugging purpose, see all the traffic going through when you connected from the client later.

1
ssserver -c /etc/shadowsocks/ss.json

Install Client

Finally, install clients on devices and start using it! You could install clients from here. For macOS, I recommend Shadowsocks X with Overseas mode.

I prefer to use Shadowsocks client with PAC rather than using proxy for the overall system.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var domains = {
  "music.163.com": 1,
  "music.126.net": 1,
  "*.v.163.com": 1,
  "*.music.163.com": 1,
  "*.music.126.net": 1,
};

var proxy = "__PROXY__";

var direct = 'DIRECT;';

var hasOwnProperty = Object.hasOwnProperty;

function FindProxyForURL(url, host) {
    var suffix;
    var pos = host.lastIndexOf('.');
    pos = host.lastIndexOf('.', pos - 1);
    while(1) {
        if (pos <= 0) {
            if (hasOwnProperty.call(domains, host)) {
                return proxy;
            } else {
                return direct;
            }
        }
        suffix = host.substring(pos + 1);
        if (hasOwnProperty.call(domains, suffix)) {
            return proxy;
        }
        pos = host.lastIndexOf('.', pos - 1);
    }
}

Netease Music

You need to select Using IE proxy.

More Information

It’s only the basic setup for Shadowsocks. For advanced topics, check