本文最后更新于 <span id="expire-date"></span> 天前,文中部分描述可能已经过时。

之前不是写了了两篇文章说 ss 断流的事吗?

  • 因为是错误的解决办法,所以加了锁

写完这两篇 ss 断流莫名其妙的好了,所以也就没管了。没想到到了这个特殊时期,有他喵的断流了,我又开始查资料,结果发现:

之前用的混淆插件早就被弃用了,改用新插件了,折腾了一下午装好插件,没想到不仅断流解决了,延迟还降了一半。

想用新插件,必须要先准备一个域名,我有一个备用的域名,所以我就直接用那个了

下载 v2ray-plugin

作者提供了编译好的,直接下载就行了

解压,复制到 VPS 的 /usr/local/bin/ 下,重命名为 v2ray-plugin,权限设为 755

配置 web 服务器

apache2

启用如下模块
sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_wstunnel
sudo a2enmod proxy_http
sudo a2enmod rewrite
sudo a2enmod headers

vim /etc/apache2/sites-available/ss.conf

将以下内容复制进去
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerName xxxxxx.com #此处改为自己的域名
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Location "/"> #此处和ss配置文件path相同
ProxyPass ws://127.0.0.1:123456/ upgrade=WebSocket #此处改为自己ss配置所对应端口
ProxyAddHeaders Off
ProxyPreserveHost On
RequestHeader append X-Forwarded-For %{REMOTE_ADDR}s
</Location>


# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

启用配置文件
cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/ss.conf
sudo service apache2 restart

nginx

vim /etc/nginx/conf.d/ss.conf
将以下内容复制进去
server {
listen 80;
server_name xxxxxx.com; # 换成你自己的域名

location / { # v2ray-plugin插件配置的path
proxy_pass http://127.0.0.1:123456; # 此处改为自己ss配置所对应端口
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
}

申请 SSL 证书

我使用的是 Let’s Encrypt的免费证书, 执行命令之前记得先将域名的A记录解析到服务器IP上,并且开放80和443端口。

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo ./certbot-auto –apache #apache
sudo ./certbot-auto –nginx #nginx

修改配置文件

默认配置文件在/etc/shadowsocks-libev/config.json , 这里采用的是Shadowsocks over websocket (HTTPS) ,在配置文件中如图修改和添加:

“server”:”127.0.0.1”,
“plugin”:”v2ray-plugin”,
“plugin_opts”:”server;path=/;loglevel=none”

修改 shadowsocks-libev.service,这里不修改会报错,我的是在/lib/systemd/system/shadowsocks-libev.service

删除 nobody 和 nogroup 两行

执行 systemctl daemon-reload 保存

然后重启 ss 即可

配置

windows 直接下载已经编译好的v2ray-plugin的windows版,解压后命名为v2ray-plugin.exe和Shadowsocks.exe放在同一文件夹下。
在Shadowsocks的服务器设置中,服务器地址填域名,端口填443,插件程序填v2ray-plugin,插件选项填tls;host=域名;path=/ 。域名要和服务端设置的一致。

android 安装v2ray-plugin-android,同样服务器地址填域名,端口填443打开Shadowsocks编辑服务器,在最下面的插件中选择v2ray,配置Transport mode为websocket-tls,Hostname为服务端设置的域名即可。

Cloudflare(可选)

将域名添加到 Cloudflare,云朵点亮

在 SSL/TLS 界面如图选择

完成之后理论上 ip 是无法被墙的,但是延迟加倍,网速减半

同样如果被墙了可以用这个方法救回来。

所以这个方法更推荐给备用梯子

评论