![](https://www.community.vpssell.com/assets/files/2024-07-31/1722423814-182257-shadowsocks.png)
Shadowsocks is a free and lightweight SOCKS5 web proxy. It is mostly used to bypass network censorship and restrictions on the Internet.
Installation
Preparation
First, update the system and install the EPEL release. Then, install additional tools necessary for SOCKS5:
yum update -y
yum install epel-release -y
yum install -y gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto udns-devel \
libev-devel libsodium-devel mbedtls-devel git m2crypto c-ares-devel
Download and Install Shadowsocks
Download Shadowsocks from GitHub and install it:
cd /opt
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
git submodule update --init --recursive
./autogen.sh
./configure
make && make install
Configuring Shadowsocks
Add System User
Add a new system user for Shadowsocks:
adduser --system --no-create-home -s /bin/false shadowsocks
Create Directory and Configuration File
Create a directory and a configuration file:
mkdir -m 755 /etc/shadowsocks
nano /etc/shadowsocks/shadowsocks.json
Configuration File Content
Add the following content to the configuration file, adjusting the values as needed:
{
"server": "your_server_IP",
"server_port": 8388,
"password": "your_password",
"timeout": 300,
"method": "aes-256-gcm",
"fast_open": true
}
Explanation of Options
- server: Your server's public IP.
- server_port: Any available port to use for the Shadowsocks proxy on your server.
- password: A password to connect to the Shadowsocks server from your device.
- timeout: Value determining when to close the session when inactive.
- method: Encryption method (e.g., "aes-256-gcm" for AEAD cipher, which is highly secure). You can browse other stream ciphers here.
- fast_open: Set to "true" if using a kernel higher than 3.7.1 to reduce latency, otherwise not necessary.
Create Systemd Service
Create Service File
Create a Systemd service for Shadowsocks:
nano /etc/systemd/system/shadowsocks.service
Service File Content
Add the following content to the service file:
[Unit]
Description=Shadowsocks proxy server
[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks/shadowsocks.json -a shadowsocks -v start
ExecStop=/usr/local/bin/ss-server -c /etc/shadowsocks/shadowsocks.json -a shadowsocks -v stop
[Install]
WantedBy=multi-user.target
Start the Service
Reload the Systemd daemon, enable the Shadowsocks service, and start it:
systemctl daemon-reload
systemctl enable shadowsocks
systemctl start shadowsocks
You can also use the "stop", "restart", or "status" options with systemctl
.
Adjust Iptables Settings
Adjust the iptables settings to allow traffic via your Shadowsocks port:
iptables -4 -A INPUT -p tcp --dport 8388 -m comment --comment "Shadowsocks" -j ACCEPT
Conclusion
Shadowsocks is now installed, configured, and hopefully running on your server. To connect to it, you will need a Shadowsocks client on your device. You can find a client for almost any device here. Install the client and connect to your Shadowsocks server using the server details configured in the /etc/shadowsocks/shadowsocks.json
file.
For more information, visit the official site or the GitHub repository.