Shadowsocks is one of the techniques that you can use to set up your VPN equivalent server. With Microsoft Azure, you can quickly set up a Ubuntu virtual machine (VM) to host Shadowsocks. But why Ubuntu? Simply because it demands less Azure resource from the cost-saving perspective than other available operating systems. Don’t worry if you barely have the knowledge in Azure or Ubuntu. Follow the steps in the article and you will get there.
Monthly cost of a Shadowsocks server in Azure
Before we start, let’s take a look at the cost of a Shadowsocks server in Azure.
- VM (Ubuntu): 22.32$/month.
- Bandwidth: Monthly cost of the first 5GB for free and 0.138$/GB onward for incoming traffic. Outbound traffic from Azure is free.
Let’s say you used 105 GB incoming data in a month which turns out to be 13.8$. Plus the VM cost, you get a total of 36.12$ for that month.
Note: The actual cost may vary over time and the geo region the VM sits in.
To set up Shadowsocks in Azure, you need to:
- Set up a Ubuntu server in Azure.
- Create a port on the server for Shadowsocks connection.
- Set up and configure Shadowsocks.
Set up a Ubuntu server in Azure
- Open the Azure portal, and log in with your Azure account (Get a one month free trial of Azure with 200$ credit).
- Click New, type Ubuntu, and then press Enter.
- Select Ubuntu Server 17.04 in the list of matches, and start creating one with the Resource Manager deployment model.
- Proceed with the following configuration for the setup:
- Use the Basic A1 plan at 22.32$/month.
- Set the Authenticate type to use Password.
- Create a new resource group to host the server.
- Set Public IP address to Static.
- Once the server is created, note down the Public IP address.
Create a port on the server for Shadowsocks connection
- Go to the resource group where the VM is hosted, find and open the <server>_nsg resource.
This resource functions as the firewall for the server. It comes with a pre-configured inbound security rule to allow management through SSH on TCP port 22.
- Add an inbound security rule by providing a name and port, and leave the rest with the default value. Here I set the port to 2000.
Set up and configure Shadowsocks
- Use an SSH client to connect to the Ubuntu server using the public IP address, which you noted down earlier, for remote management. PuTTY is the client I use on Windows.
Upon connection, an SSH client window opens.
- Update Ubuntu to the latest version in the SSH client window by running the following commands:
sudo apt update
sudo apt dist-upgrade
- Install Shadowsocks.
sudo apt install shadowsocks-libev
- Configure Shadowsocks.
- Open the config.json file.
sudo vim /etc/shadowsocks-libev/config.json
- Press I to switch to the editing mode.
- If you have a single port created in the <server>_nsg resource:
- Set server to 0.0.0.0.
- Set server_port to the port you created in the <server>_nsg resource.
- Set password to the password of your Ubuntu server.
- Set method to “aes-256-cfb”.
- Press ESC, and then type :wq to save the file.
- Open the config.json file.
- In the Azure portal, restart the Ubuntu server.
Note: The setup has configured Shadowsocks to automatically start with Ubuntu.
- Verify if the ShadowSocks server is listening on the port, in this case 2000.
If the port was not listened, restart ShadowSocks.
service shadowsocks-libev restart
- Download the Shadowsocks client that is available on Android, iOS, Windows and macOS. For Android and iOS, you may have to get the client from the US app store.
- Open the Shadowsocks client, enter the connection information and make the connection. You also have the option of enabling Shadowsocks to handle the traffic only to sites outside of China.
Congratulations! Now you are all set. Enjoy Shadowsocks!