--- tags: tools --- # Scientific Surfing Setup Guide This note provides guidance on how to setup the Shadowsocks and V2Ray on the server side, and create a subscription link for clients. ## Install ShadowSocks ```shell= apt install -y shadowsocks-libev ``` Edit the configuration file in `/etc/shadowsocks/config.json` as the following: ```json= { "server": "<ip to bind>", "server_port": <port #>, "local_port":0, "password": "<any string>", "timeout": 60, "method": "aes-128-gcm" } ``` To enable and start the service, run ```shell= systemctl enable shadowsocks-libev-server@config systemctl start shadowsocks-libev-server@config ``` ## Install V2Ray The V2Ray developers provide a handy installer script. Simpy run the following: ```shell= curl -Ls https://install.direct/go.sh | sudo bash ``` Edit the configuration file `/usr/local/etc/v2ray/config.json`: ```json= { "log": { "loglevel": "warning", "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log" }, "inbounds": [ { "listen": "0.0.0.0", "port": <port #>, "protocol": "vmess", "settings": { "clients": [ { "id": "52c9448d-bed7-c78d-dcd6-8f109f35b13b", "alterId": 64 } ] } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ] } ``` To enable and start the service, run ```shell= systemctl enable v2ray systemctl start v2ray ``` ## Set Up the Subscription Link The subscription link is for the users to automatically update their client-side configuration whenever the server-side configuration changes. *Note: the link is only tested to work on these clients:* - *V2rayU (MacOS)* - *ShadowRocket (IOS).* ### Generate the client configuration files to be imported Whenever the server-side config changes, go to the directory ```shell= cd /etc/v2ray/client_configs ``` and then update the corresponding client-side configs in the file `clients.conf`. A sample client config looks like the following: ```json= [ { "protocol": "vmess", "method": "aes-128-gcm", "passwd": "<client id>", "server": "<server ip>:<port>", "options": "remarks=Pascal&obfs=none&tfo=1" }, { "protocol": "ss", "method": "aes-128-gcm", "passwd": "<any string>", "server": "<server ip>:<port>", "options":"plugin=obfs-local;obfs=tls;obfs-host=obfs=http;obfs-host=www.bing.com;obfs-uri=/&tfo=1#Pascal%20SS" } ] ``` Then run the script to encode it into base64 format: ```shell= ./encode ``` The script requires `jq` to be installed: ```shell= sudo apt-get install jq ``` Two files will be generated: - `urls.txt` contains the client config links that can be import with any compatible client, and - `sub.txt` is the base64 encoding of the `urls.txt`, which can be decoded by the compatible clients. ### Publish the encoded client config links by url This guide uses the NGINX server to publish the client configs. I will not elaborate on how to install and run the NGINX server here and this notes assumes one has a running NGINX server already. Create a location directive in the NGINX config file, usually found at `/etc/nginx/sited-available/default`: ```nginx= location /config/ { alias <parent directory containing the file sub.txt>; error_page 404 /404.html; error_page 403 /403.html; } ``` Then one can use the subscription link `http(s)://<domain.name>/config/sub.txt` to import the configs.