First of all, a full blown tutorial on this can accessed on my blog via this link. If you want a quicker way and you already meet the prerequisites, then follow along with this README. My Terraform code was written following some of Google Cloud best practices for Terraform and it will deploy a Shadowsocks proxy server in less than 90 seconds.
- A Google Cloud account.
- A GCP project with billing enabled.
- A service account for Terraform with enough privileges to deploy resources or use other authentication methods for authenticating terraform cli. You can learn about more authentication mechanisms via this link.
- gcloud CLI installed.
- Terraform cli installed.
export TF_VAR_project="<your-project-name>"
Note:- The above environment variable is necessary and must be set up before doing anything else.
gcloud services enable compute.googleapis.com cloudresourcemanager.googleapis.com
ssh-keygen -t rsa -b 4096
Note:- I recommend setting a password for the ssh keys.
git clone https://github.com/GenialHacker/tf-shadowsocks.git
cd tf-shadowsocks
terraform init
terraform fmt
terraform validate
First, check whether the correct project is set up or not.
echo $TF_VAR_project
Next, apply the configuration to deploy Shadowsocks server.
terraform apply
When the deployment of server finishes, you'll be provided the IP address and the password for shadowsocks proxy server which would be hidden. To show the password use the following command:-
terraform output sss_password
apt update && apt install shadowsocks-libev
systemctl stop shadowsocks-libev
systemctl disable shadowsocks-libev
cp /etc/shadowsocks-libev/config.json /etc/shadowsocks-libev/gcp.json
Next, edit /etc/shadowsocks-libev/gcp.json
and populate it something like this.
{
"server":"your-ss-server-ip-address-from-above",
"mode":"tcp_and_udp",
"local_address":"127.0.0.1",
"server_port":8888,
"local_port":1080,
"password":"your-password-from-terrafrom-output-above",
"timeout":86400,
"method":"chacha20-ietf-poly1305"
}
systemctl restart [email protected]
curl --proxy socks5://127.0.0.1:1080 https://ifconfig.me
If the above command shows your Shadowsocks server IP, then your proxy is fully setup!