Shadowsocks + Cloak

Cloak disguises a proxy or VPN server as a web server in order to evade deep packet inspection (DPI). The disguised server secretly implements Shadowsocks, OpenVPN, or Tor.

In this article, we deploy Shadowsocks and Cloak on a Debian 10+ server, with a camouflage website running on Nginx. Before you set up your server:

In the examples in this article, we give the server host name as and the server IP address as yy.yy.yy.yy.

If your server or client runs a recent version of Ubuntu, the procedures will be very similar to those for Debian 10+.

We end the tutorial by describing the procedure for setting up a Windows client.

From Firefox to Shadowsocks to Cloak

1. Set Up Camouflage Web Server

1.1. Open Firewall

Firewalls are typically implemented with nftables, iptables, ufw, firewalld, or security groups. Whichever one you are using, you will need to open ports 80 and 443 for TCP input and persist your changes across reboots.

For example, if you are using nftables with a policy of drop on Debian 10+, the commands would be:

nft add rule inet filter input tcp dport { http, https } counter accept
nft list ruleset > /etc/nftables.conf

If you are using nftables, then enter the commands above. If you are not using nftables, then make the equivalent changes for your firewall.

1.2. Implement BBR

Bottleneck Bandwidth and Round-trip propagation time (BBR) is a TCP congestion control algorithm developed at Google. Under certain types of network congestion, it will improve your latency. Implement BBR TCP congestion control on your server with the following commands:

cat >> /etc/sysctl.d/50-bbr.conf <<EOF
sysctl -p /etc/sysctl.d/50-bbr.conf

1.3. Install Nginx

Install the Nginx web server on your server:

apt update && apt upgrade -y
apt install nginx -y

1.4. Configure Nginx

We want to make the Nginx web site look as much as possible like a realistic production server. Therefore edit the main Nginx configuration file:

vi /etc/nginx/nginx.conf

Uncomment the line:

server_tokens off;

Save the main Nginx configuration file. Then edit the default site definition file:

vi /etc/nginx/sites-available/default

Insert the real server name, which in our example is


Immediately below that, insert lines that will allow only expected HTTP request methods:

    if ($request_method !~ ^(GET|HEAD|POST)$ )
            return 405;

Also add a line to provide some realistic browser caching:

expires 1h;

Save the default site definition file. Restart Nginx for all your changes:

nginx -t
systemctl restart nginx

1.5. Add Camouflage Content to Web Server

Add a few realistic webpages to your camouflage site. Here is an example of how you might do that. You can add different content if you have some.

apt install wget zip unzip -y
cp -rf sample-blog-master/html/* /var/www/html/

At this point, you can test to see if your host name resolves to your IP address by opening a browser on your PC and visiting the HTTP version of your site. Using our example of a host named, that would be:

1.6. Add SSL Certificate to Web Server

Now we make the site accessible by HTTPS on port 443, following the instructions for Nginx and Debian 10 on the Certbot website.

apt install certbot python-certbot-nginx -y
certbot --nginx
certbot renew --dry-run

You now have a working HTTPS camouflage website with a few sample pages on it. Test this by opening a browser on your PC and visiting the HTTPS version of your site. In our example, that would be:

2. Install Shadowsocks on Server

2.1. Generate Password

Generate a strong password for Shadowsocks:

openssl rand -base64 24

You will receive a 192-bit password, expressed as 32 base-64 characters, which looks like this:


2.2. Install Shadowsocks-Libev

Use the Teddysun script to install Shadowsocks-Libev on the server:

chmod +x
  1. When asked to input the password, enter your generated strong password, which in our example is IMC/Coe/bkfXQw7nvqqCm3Q/RBGgp1j2
  2. When asked to enter a port, enter 8388
  3. When asked to choose a cipher, enter 3, which stands for aes-128-gcm
  4. Press any key to run the script, or Ctrl+c to cancel

The script downloads, compiles, configures, and runs the software. At the end of the script, it displays some confirmation messages:

Congratulations, Shadowsocks-libev server install completed!
Your Server IP : YY.YY.YY.YY
Your Server Port : 8388
Your Password : IMC/Coe/bkfXQw7nvqqCm3Q/RBGgp1j2
Your Encryption Method: aes-128-gcm

The script places the configuration in /etc/shadowsocks-libev/config.json. The Shadowsocks binaries are in /usr/local/bin. The executable ss-server is already running in the background and listening on port 8388.

3. Install Cloak on Server

3.1. Move HTTPS Site to Port 8443

Right now, Nginx is listening on ports 80 and 443. We’re going to make Cloak listen on port 443, so we’ll move Nginx and make it listen on port 8443 instead.

Edit the Nginx default site definition file:

vi /etc/nginx/sites-available/default

Change the lines that make the SSL server listen on port 443 to make it listen on port 8443:

listen [::]:8443 ssl ipv6only=on; # managed by Certbot
listen 8443 ssl; # managed by Certbot

Save the default site definition file. Restart Nginx to make this change take effect:

systemctl restart nginx

3.2. Download Cloak

Open a browser on your PC and visit the GitHub Cloak releases page. Determine the version number of the latest release. For example, right now it is 2.5.4.

On your server, download the latest binary for 64-bit Linux:


Copy the binary into a directory in your path with the name ck-server:

cp ck-server-linux-amd64-v2.5.4 /usr/local/bin/ck-server

Make ck-server executable:

chmod +x /usr/local/bin/ck-server

Allow Cloak to bind to privileged ports (i.e. TCP/IP port numbers below 1024):

setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/ck-server

3.3. Generate Public-Private Key Pair

Generate a public-private key pair:

ck-server -k

The public key and private key are delivered, separated by a comma. Here is an example of what the result might look like:


3.4. Generate Administrator Id

Generate a secret identifier for the administrator like this:

ck-server -u

It will produce a base-64 string that looks like this:


3.5. Generate User Id

Generate an identifier for an ordinary user. We will make this user have no bandwidth or credit limit restrictions.

ck-server -u

The command will produce a base-64 string that looks like this:


3.6. Configure Cloak

For your reference, there is a sample configuration file on GitHub.

Create a directory for Cloak:

mkdir /etc/cloak

Edit your server’s configuration file for Cloak:

vi /etc/cloak/ckserver.json

Insert contents like the example below, substituting in your user id, private key, and administrator id:

  "ProxyBook": {
    "shadowsocks": [
  "BindAddr": [
  "BypassUID": [
  "RedirAddr": "",
  "PrivateKey": "MF2tHiGXjP3P3fIIxjt02un2G0qtXdbArmrWsTfz7FM=",
  "AdminUID": "SI6bHNp9+Mlc0+/LxhhYig==",
  "DatabasePath": "/etc/cloak/userinfo.db",
  "StreamTimeout": 300

Save the Cloak server configuration file.

3.7. Configure Systemd for Cloak

Create a systemd service file, so that we can make Cloak start after every reboot and run continually as a service:

vi /usr/lib/systemd/system/cloak.service

Insert contents like this:

Description=Cloak Server

ExecStart=/usr/local/bin/ck-server -c /etc/cloak/ckserver.json


Save the file.

3.8. Run Cloak

Make Cloak start after every reboot and run continually as a service:

systemctl enable cloak
systemctl start cloak

Check the status of the Cloak service:

systemctl status cloak

The above command should show that Cloak is active (running). Type q to quit the status display. Check what is listening on port *443:

ss -tulpn | grep 443

The above command should show that:

Your work on the server is done for now, so exit your SSH session with the server:


3.9. Check from PC

From your PC, check what an unauthorized visitor to your server would see. In our example, the address to put into your browser would be:

You should see an ordinary looking website.

4. Set Up Windows Client

Now work on your PC, which in this tutorial is running Windows.

4.1. Download Cloak Client

In your browser, visit GitHub and determine the latest version of Cloak. We will use version 2.5.4 as our example.

Download Cloak client from GitHub

Download ck-client-windows-amd64-v2.5.4.exe from GitHub to your PC’s Downloads directory.

Keep the download in Microsoft Edge

4.2. Configure Cloak Client

For your reference, there is a sample client configuration file on GitHub.

In the Downloads folder, create a client configuration file for Cloak named ckclient.json. You can use Notepad or Notepad++ to edit the file. Insert contents like the example below, substituting in your UID, PublicKey, and ServerName:

  "Transport": "direct",
  "ProxyMethod": "shadowsocks",
  "EncryptionMethod": "plain",
  "UID": "lNEQtGxl6BgYmVg9N5kBRA==",
  "PublicKey": "eRx9vO3x8i1hJ9PucrnlUsN74J/g7MPLymUJCrrQJVM=",
  "ServerName": "",
  "NumConn": 4,
  "BrowserSig": "firefox",
  "StreamTimeout": 300
Configuration file for Cloak client

Save the file.

4.3. Run Cloak Client

Open a Windows Command Prompt window (Win+r, then cmd).

Change into your Downloads directory:

cd Downloads

Run Cloak, pointing to your configuration file ckclient.json and your server yy.yy.yy.yy:

ck-client-windows-amd64-v2.5.4.exe -c ckclient.json -s yy.yy.yy.yy
Running Cloak client in a Windows Command Prompt window

4.4. Download Shadowsocks for Windows Client

Open Firefox, and visit GitHub and determine the latest version of Shadowsocks for Windows. We will use version as our example.

Download Shadowsocks client for Windows from GitHub

Download the zip file, which in this example was named

Unzip the zip file to give a folder named Shadowsocks- The Shadowsocks executable program is inside that folder.

Extract Shadowsocks client for Windows

4.5. Configure Shadowsocks

Launch the Shadowsocks executable. Configure a server as follows:

Click Apply. Click OK.

Configure Shadowsocks for Windows

4.6. Configure Proxy Settings

Right-click on the Start button, and open the Windows Settings app.

Windows Settings app on Start menu

Go to Network and Internet, then Proxy.

  1. Toggle Use a proxy server to the ON position
  2. Enter Address
  3. Enter Port 1080
  4. Don’t use the proxy server for localhost
  5. Check the box for Don’t use the proxy server for local (intranet) addresses
  6. Click Save
Manual proxy configuration in Windows

4.7. End-to-End Test

Check the end-to-end functionality to confirm that Shadowsocks, Cloak, and Firefox are all configured correctly. Visit IP Chicken. You should see the IP address of the server, not your local client.

5. Get Help and Report Issues

Updated 2021-06-23