苹果 iOS 使用 Shadowsocks 设置教程

https://shadowsockshelp.github.io/Shadowsocks/ios.html

第一步 下载手机客户端

1、登陆苹果非大陆区账号单独购买下载,以下是苹果商店链接(需非大陆苹果账号,选择任意一个下载即可)。

苹果美区商店 App Store下载:【推荐 Shadowrocket小火箭 - App Store Potatso Lite代理工具 - App Store

2、代理软件在iOS国区里已经下架了,需要登录非国区ID才能下载,非常的麻烦而且有些小白也会登录iCloud的,挺危险的,所以推荐在线安装一步到位(选择任意一个在线安装即可)。

苹果手机游览器打开 在线安装:【 Shadowrocket小火箭在线安装 Potatso Lite代理工具 在线安装

3、苹果美区账号分享 详见: APPLE ID 免费账号共享

第二步 获取 Shadowsocks 账号信息

一个可用的 Shadowsocks 账户(需要包括以下信息:服务器地址、端口号、加密方式、密码)

详见:SS/ShadowsocksR 服务器节点 点击获取

第三步 iOS配置 Shadowsocks 客户端

一、Shadowrocket 小火箭 设置教程

添加 Shadowsocks 账户

Shadowrocket 是一款专门为 Shadowsocks 设计的 APP,所以添加起来也是极其方便。点击左上角的方框即可扫描 Shadowsocks 账户服务器节点的二维码,免去输入的麻烦。

第一次连接时会弹出一个添加代理的提示框,点“Allow”允许,否则不能用。如果你有多个节点,连接后是使用前面有圆点的节点,点击节点即选中作为默认,选中的节点使用中无法删除。

或者你也可以点击右上角的加号进行手动输入

规则的设置

一般全局路由选择默认配置即可,如果要实现部分网站国内走直连,国外走代理的话,就需要用到规则。

点击 Settings,然后在点击 Config 你就可以看到以下界面

点击 + 通过添加链接,在点击 Use Config 来下载规则文件。你可以对其进行编辑,以满足自己的使用习惯。点击感叹号,然后在点击 Add Rule,点击 Type,就可以看到多种过滤方式进行设置了。

节点订阅设置

打开Shadowrocket,点击右上角加号 + ,在添加节点页面,将类型改为第三个 Subscribe,复制订阅地址粘贴到URL中,然后点击右上角完成即可。

在Shadowrocket设置–服务器订阅中打开【打开时更新】选项。

回到首页,打开连接开关,享受科学上网吧!


二、Potatso Lite 代理工具 设置教程

从 App Store 安装后打开 Potatso Lite。点击 “立即使用” > “现在添加”。

扫码配置

点击 “二维码” > “Potatso Lite 想访问您的相机”的窗口,选择 “好” > 扫描你节点的二维码,节点将自动添加成功。

手动配置

1、点击 “添加” > 填写代理。

2、选择 “Shadowsocks“ > 填写 “服务器” > 填写 “端口” > 选择 “加密” > 填写 “密码” 。

3、填写 “备注” 为可选项 > 点击右上角的 “✔”, 设置完成。

开始代理

1、点击 “开始” > 选择 “Allow” > 开启 “智能路由”。

2、当看到左上角出现 VPN 字样时,代表连接成功。

3、智能路由 表示可以实现自动代理, 及本来可以访问的网站不会经过代理,推荐日常使用。

最后 若无法打开网页,可以进行如下测试

1、可以尝试小火箭软件最下面一排按钮,选择-配置 页面,点击 恢复默认配置。

2、更换手机4G网络进行尝试、重启路由器更改IP。

3、下载其他代理软件尝试, 推荐 如 Potatso Lite ,请使用 美区账号登陆App Store 搜索下载安装。

需要再次说明的是

1、由于 shadowrocket 等软件 不在部分国家如中国等商店上架,因此需要使用美国/香港等appstore账号才可下载。

2、苹果美区账号分享 详见: APPLE ID 免费账号共享

3、使用共享账号登录,切记请勿登录iCloud。

How to install Shadowsocks-libev SOCKS5 proxy server

https://upcloud.com/community/tutorials/install-shadowsocks-libev-socks5-proxy/

Shadowsocks is a free open-​source SOCKS5 proxy widely used to protect privacy on the Internet. Shadowsocks-​libev, written in C, ports Shadowsocks to create a regularly maintained, lighter and faster version of the original Shadowsocks. The data passing through the Shadowsocks-​server and Shadowsocks-​client is encrypted and can be made indistinguishable from any other web traffic to avoid third-​party monitoring.

In this tutorial, we’ll show the steps for installing Shadowsocks-​libev on a cloud server, configuring the proxy server, and using a client to connect to the proxy. The instructions are given here for CentOS 8, Debian 10 and Ubuntu 20.04 but the process should be much the same on any operating system supported by Snap.

Test hosting on UpCloud!

Installing Shadowsocks-​libev

Shadowsocks-​libev recommends using their Snap releases for an easy way to install the latest binaries.

On CentOS 8 servers you will need EPEL repository before you can install Snap. Add it using the following commands:

sudo dnf install -y epel-release
sudo dnf update -y

Then install and enable Snap by running the next two commands:

sudo dnf install -y snapd
sudo systemctl enable --now snapd.socket

For Debian 10 and Ubuntu 20.04 systems, first, update the server software and then install Snap with the commands below.

sudo apt update && apt upgrade -y
sudo apt install -y snapd

Before installing Shadowsocks-​libev, you may wish to install haveged to improve randomness but this is optional.

# CentOS 8
sudo dnf install -y haveged
# Debian 10 and Ubuntu 20.04
sudo apt install -y haveged

Once you have Snap and the optional haveged installed, reboot the server before continuing.

sudo reboot

When your cloud server is up and running again, log back in over SSH. Then install Shadowsocks-​libev proxy via Snap using the following command:

sudo snap install shadowsocks-libev

Once you’ve installed Shadowsocks-​libev, continue to the next section about how to configure the proxy server.

Configuring proxy server

Snap will install Shadowsocks-​libev for you but it’ll need a little help with the setup. Make a directory to hold your configuration files.

sudo mkdir -p /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev

Next, create a JSON file for Shadowsocks-​libev configuration. It can be named anything. Here we are using simple config as the name.

sudo touch /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev/config.json

Then edit the file and add the following configuration to the file.

sudo nano /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev/config.json
{
   "server":["[::0]", "0.0.0.0"],
   "mode":"tcp_and_udp",
   "server_port":443,
   "password":"your-secure-password",
   "timeout":60,
   "method":"chacha20-ietf-poly1305",
   "nameserver":"1.1.1.1"
}

Let’s go over each of the configuration parameteres and what they do.

Server

The example configuration uses the server definition values which accept any IP address, both IPv6 and IPv4:

"server":["::0", "0.0.0.0"],

Not binding to a specific address can be useful if you wish to create a template of the configuration or a custom image of your Shadowsock server. This way the configuration will work regardless of the public IP address.

You can also use your public IPv6 and IPv4 addresses, for example:

"server":["2a04:3543:1000:2312:4631:c1ff:feb5:01f0", "95.123.198.234"],

If you have a domain name that resolves to your cloud server’s IP address, you can also use it to have the proxy only respond to a certain domain.

"server":"shadow.example.com",

Mode

The different modes define the data communication protocol used by the proxy. There are three valid values for “mode”:

1. “tcp_​and_​udp“
2. “tcp_​only“
3. “udp_​only”

Using both TCP and UDP allows the proxy to negotiate the best connection available at the time and should be fine. If your network has specific requirements or restrictions, you may need to select tcp_​only.

Server port

Our example Shadowsocks config uses the port 443 but it can be set to any free port. If you’re not using HTTP (80) or HTTPS (443) ports by hosting a website on the same server, you should use either of these ports. Note that using a common port such as 80 or 443 can attract unauthorised connection attempts so make sure your password is secure.

Password

The server password is used to authenticate connections to the proxy. Make sure to select a secure password with adequate complexity and length.

Timeout

This is the socket timeout in seconds. The example value of 60 should be fine. However, if you installed Shadowsocks from backports you might need to set it higher but it’s suggested you keep it under 5 minutes, i.e. 300 seconds.

Method

The method refers to the encryption cipher used by the proxy to secure the communications. The cipher used in the example config is a modern and efficient option:

"method":"chacha20-ietf-poly1305"

You can choose other ciphers if you want. Another popular alternative is:

"method":"aes-256-gcm"

Nameserver

Our example also includes a domain name server which is not strictly necessary. Without this parameter the proxy will use the DNS used by your cloud server. You can have Shadowsocks use your preferred DNS by setting the nameserver in your config file.

For example, to use Google’s DNS, enter the following:

"nameserver":"8.8.8.8"

Or if you prefer Cloudflare’s DNS, use their IP address instead:

"nameserver":"1.1.1.1"

Once you are done editing the configuration, save the file ctrl+o and exit the editor ctrl+x.

Creating systemd service unit

Shadowsocks-​libev can be run manually in the terminal but this isn’t very practical in the long-​term. Instead, create a systemd service unit file using the following command:

sudo touch /etc/systemd/system/shadowsocks-libev-server@.service

Next, open the newly created file for edit:

sudo nano /etc/systemd/system/shadowsocks-libev-server@.service

Then copy and paste the following content into the file:

[Unit]
Description=Shadowsocks-Libev Custom Server Service for %I
Documentation=man:ss-server(1)
After=network-online.target
    
[Service]
Type=simple
ExecStart=/usr/bin/snap run shadowsocks-libev.ss-server -c /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev/%i.json
    
[Install]
WantedBy=multi-user.target

Afterwards, save the file and exit the editor.

You can then enable the systemd service unit for your config file by running the following command. Note that the @config is used to select the configuration file, config.json in this case, but without the file format notation.

sudo systemctl enable --now shadowsocks-libev-server@config

Check that the server started up successfully by using the status command:

sudo systemctl status shadowsocks-libev-server@config

You should see Shadowsocks listening to the IP addresses, ports and protocols you defined in the configuration. In our example output below, you can see both TCP and UDP running on IPv4 and IPv6 addresses as set in the configuration step.

● shadowsocks-libev-server@config.service - Shadowsocks-Libev Custom Server Service for config
     Loaded: loaded (/etc/systemd/system/shadowsocks-libev-server@.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-30 10:37:06 UTC; 3s ago
       Docs: man:ss-server(1)
   Main PID: 1229 (ss-server)
      Tasks: 1 (limit: 1074)
     Memory: 18.0M
     CGroup: /system.slice/system-shadowsocksx2dlibevx2dserver.slice/shadowsocks-libev-server@config.service
             └─1229 /snap/shadowsocks-libev/508/bin/ss-server -c /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev/config.json

Aug 30 10:37:06 shadowsocks.example.com systemd[1]: Started Shadowsocks-Libev Custom Server Service for config.
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: UDP relay enabled
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: initializing ciphers... chacha20-ietf-poly1305
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: using nameserver: 1.1.1.1
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: tcp server listening at [::0]:443
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: tcp server listening at 0.0.0.0:443
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: udp server listening at [::0]:443
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: udp server listening at 0.0.0.0:443
Aug 30 10:37:07 shadowsocks.example.com snap[1229]:  2020-08-30 10:37:07 INFO: running from root user

With Shadowsocks-​libev proxy server up and running, we are almost ready to start testing the connection. Before then, check the next part of the tutorial to configure your firewall to allow a connection.

Allowing connection through firewall

If you are using a firewall like UFW or firewalld, make sure you open up the port used by server_​port as set in the configuration file, port 443 in this example.

# Ubuntu
sudo ufw allow 443
# CentOS
sudo firewall-cmd --add-service=https --permanent
sudo firewall-cmd --reload

If you’re not using a software firewall on your server we recommend enabling the UpCloud’s Firewall service on your cloud server.

Check out the tutorial for managing UpCloud Firewall to find out more.

Connecting using proxy client

Shadowsocks-​libev is now ready for proxy connections. To be able to connect to your Shadowsocks proxy server, you’ll need a client.

Client software

Shadowsocks is supported by a number of different clients and devices. You can find the list of available clients for your devices at the Shadowsocks download page.

Install a client of your choosing and test out the connection with the help of the details below.

For example, you can use the same Shadowsocks-​libev software in client mode by installing it on your local system. Follow the installation steps like when installing the Shadowsocks-​libev server then continue in the Linux client configuration step underneath.

Configuring mobile devices

As a light-​weight proxy, Shadowsocks-​libev works great with mobile devices. If you want a quick way to connect using a smartphone, go to the Shadowsocks’ QR generator and fill your config details in the following format:

ss://method:password@hostname:port

Replace the hostname with your server’s public IP if you are using the IPs instead of a domain name. For example:

ss://chacha20-ietf-poly1305:your-secure-password@95.123.198.234:443

Then import the generated URI or QR code on your device using the client software. Select the imported profile and activate the connection. And finally, configure your system to use the proxy.

In mobile devices like iOS and Android, the connection can serve as a full VPN.

Configuring another Linux host

Connecting using the Shadowsock-​libev as a client can be done by configuring the proxy in localhost mode. Once installed, create local-config.json file as underneath.

Set the file to include the server IP address and port as you configured on the proxy server. Also, include local address and port like shown below. Lastly, set the password and encryption method to match your Shadowsocks proxy server.

sudo nano /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev/local-config.json
{
    "server":"95.123.198.234",
    "server_port":443,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"your-secure-password",
    "timeout":60,
    "method":"chacha20-ietf-poly1305"
}

Next, create a systemd unit file for the Shadowsocks client and edit it to have the following content.

sudo nano /etc/systemd/system/shadowsocks-libev-local@.service
[Unit]
Description=Shadowsocks-Libev Local Service for %I
Documentation=man:ss-local(1)
After=network-online.target
    
[Service]
Type=simple
ExecStart=/usr/bin/snap run shadowsocks-libev.ss-local -c /var/snap/shadowsocks-libev/common/etc/shadowsocks-libev/%i.json
    
[Install]
WantedBy=multi-user.target

Once done, save the file and exit the editor.

Then start the client proxy using the following command. Note that the @config is used to select the configuration file, e.g. config.json but without the file format.

sudo systemctl start shadowsocks-libev-local@local-config

The local proxy creates a connection to your cloud server and allows data to pass through them. To actually have application data to use the proxy, you’ll need to configure your web browser or operating system to use the local proxy. The actual process depends on your use case but by our configuration, the proxy is running on the IP 127.0.0.1 and port 1080.

Testing the connection

Once you are connected, check that your traffic is running through the proxy. For example, open the following URL to test the IP address you are connecting from as seen by others on the Internet.

https://ifconfig.me

Alternatively, you can test it directly by using curl in the terminal:

curl --proxy socks5://127.0.0.1:1080 https://ifconfig.me

Or by starting Google Chrome with the following command-​line option:

google-chrome --proxy-server="socks5://127.0.0.1:1080"

You should then see your connection details listing the IP address of your cloud server instead of the IP of your client device.

Note that using a VPN connection to your cloud server does not guarantee anonymity and any network traffic must comply with UpCloud Terms of Service and Acceptable Use Policy.

Making further optimisations

You should now have a fully functional proxy securing your connection to your cloud server. You may not need any additional optimisations, but in the off-​chance that you are having a less than ideal experience, the following tweaks might help.

Increasing open file descriptors

Check the current values by running:

ulimit -aH

If open files parameter shows less than 51200, do the following:
Open the limits.conf file in a text editor.

sudo nano /etc/security/limits.conf

Then add the following lines just before the # End of file:

* soft nofile 51200
* hard nofile 51200

Alternatively, use the following if the proxy server is running as root:

root soft nofile 51200
root hard nofile 51200

Afterwards, save the file and exit the editor.

Tuning the kernel parameters

Depending on the performance of your proxy server, you may wish to make the following changes to your system configuration:

sudo nano /etc/sysctl.conf

Add the following lines to the end of the file:

fs.file-max = 51200
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.core.netdev_max_backlog = 4096
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mtu_probing = 1
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864

Then save the file and run the command below to reload the settings.

sudo sysctl -p

Using TCP BBR

TCP BBR is a TCP congestion control algorithm developed by Google and its been reported to improve performance on certain networks. You can enable it by adding the following to lines to your system configuration file.

sudo nano /etc/sysctl.conf
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

Then save the file and reload the settings.

sudo sysctl -p

Check the changes by running the next command.

sudo sysctl net.ipv4.tcp_congestion_control

If the output is as follows the setting was applied successfully.

net.ipv4.tcp_congestion_control = bbr

These optimisations should help alleviate any possible performance issues.


https://upcloud.com/community/tutorials/install-shadowsocks-libev-socks5-proxy/

使用Docker部署Shadowsocks

摘要

本文介绍如何使用Docker部署Shadowsocks,并且开启ipv6

先拉取镜像

docker pull shadowsocks/shadowsocks-libev

不带IPV6版本

docker run -d \
  -e PASSWORD=<password> \
  -e METHOD=aes-256-cfb \
  -e DNS_ADDRS="<dns_server>" \
  -p <server-port>:8388 \
  -p <server-port>:8388/udp \
  --name=ss_server_test \
  --restart=unless-stopped \
  shadowsocks/shadowsocks-libev

以下是一个可以用来开启多个ss_server的脚本

#!/bin/bash

base=20000

cat userlist | while read line
do
        #echo $line;
        port=`echo $line | cut -d ' ' -f 1`
        port=`expr $port + $base`
        user=`echo $line | cut -d ' ' -f 2`
	docker rm -f ss_server_$user
done

cat userlist | while read line
do
	#echo $line;
	port=`echo $line | cut -d ' ' -f 1`
	port=`expr $port + $base`
	user=`echo $line | cut -d ' ' -f 2`
	echo port:[$port] user:[$user]
	docker run -d \
	  -e PASSWORD=$user \
	  -e METHOD=aes-256-cfb \
	  -e DNS_ADDRS="100.100.2.136,100.100.2.138" \
	  -p $port:8388 \
	  -p $port:8388/udp \
	  --name=ss_server_$user \
	  --restart=unless-stopped \
	  shadowsocks/shadowsocks-libev
done

带IPV6版本

带ipv6的话为了方便起见直接使用host的网络

docker run -d \
  --net="host" \
  --name=ss_server_ipv6 \
  -v /root/manager/shadowsocks/manager6.json:/manager6.json \
  shadowsocks/shadowsocks-libev \
  ss-server \
    -c /manager6.json \
    -d 2001:19f0:300:1704::6,108.61.10.10

其中manager6.json如下

{
    "server":["::","0.0.0.0"],
    "server_port":<server-port>,
    "password":"<password>",
    "timeout":300,
    "method":"aes-256-cfb",
    "fast_open":true,
    "prefer_ipv6": true,
    "mode":"tcp_and_udp"
}