Skip to main content

ShadowSocks Tutorial

安装 Shadowsocks + v2ray-plugin + Nginx

i 信息提示

使用cloudflare代理域名来搭建节点 低延迟,高安全,隐匿性比较好

sudo apt update
sudo apt install -y shadowsocks-libev nginx unzip curl
wget https://github.com/shadowsocks/v2ray-plugin/releases/download/v1.3.2/v2ray-plugin-linux-amd64-v1.3.2.tar.gz
tar -xzvf v2ray-plugin-linux-amd64-v1.3.2.tar.gz
sudo mv v2ray-plugin_linux_amd64 /usr/local/bin/v2ray-plugin
sudo chmod +x /usr/local/bin/v2ray-plugin

配置 Shadowsocks 服务

sudo vim /etc/shadowsocks-libev/config.json
{
"server": "127.0.0.1",
"server_port": 10000,
"password": "MyPass2025",
"timeout": 60,
"method": "aes-256-gcm",
"plugin": "v2ray-plugin",
"plugin_opts": "server;path=/ssws;host=stable-anius.top"
}

配置 Nginx + TLS(推荐使用 Let's Encrypt 自动证书)

sudo apt install -y certbot python3-certbot-nginx
// stable.anius.top域名商申请的,保证可以请求正常
sudo certbot --nginx -d stable.anius.top

获取成功后,配置 Nginx:

server {
listen 443 ssl http2;
server_name stable.anius.top;

ssl_certificate /etc/letsencrypt/live/stable.anius.top/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/stable.anius.top/privkey.pem;

include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

location /ssws {
proxy_pass http://127.0.0.1:10000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
# 禁用普通 HTTP 请求直接访问
if ($http_upgrade != "websocket") {
return 403;
}
}

location / {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
}
}

server {
listen 80;
server_name stable.anius.top;
return 301 https://$host$request_uri;
}

w 警告提示

cloudflare的SSL/TLS 加密当前加密模式:完全(严格)否则会一直重定向

启用站点配置:

sudo ln -s /etc/nginx/sites-available/ss.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

启动 Shadowsocks 服务

sudo systemctl restart shadowsocks-libev

查看Shadowsocks 状态

sudo systemctl status shadowsocks-libev

w 警告提示

服务器的安全组需要开启http(80)和https(443)端口才可以