MENU

sspanel 魔改版搭建与节点中转加速 CSGO

April 30, 2017 • Read: 26905 • 越过长城,代码,应用

之前的 ss-bash 虽然也挺好用,也很轻量,但不方便搞端口转发,也不适合我继续当奸商,所以就顺手花了一晚上搭了原版的 sspanel,用了两天,也在校内小小推广了一波,发现这个系统不支持支付接入,无奈又换用 sspanel 魔改版,断断续续折腾了两天,结果悲剧的发现魔改版是支持支付接入,但是。。。个人账户必须调用第三方免签约的服务,而这些服务。。。算了。。。我的事业还没开始呢。。。

网上所有的魔改版的教程都过时了,作者新添加了一些功能,导致以前的方法不对,写一写我自己踩的坑吧。

LNMP 环境

用的是 oneinstack 集成包,虽然安起来慢,不过版本比较新,而且自带了几个常用的脚本,挺好用的。

照着 这里 的教程来就可以了,注意安装完成后他会给你加上防火墙,如果你有别的服务在跑,可以等他安完了再去改一下。

安好后会自带一个默认服务,跑着 phpinfo 和一个探针,这些东西泄露服务器信息,肯定不能要,安好后看看功能正常就可以删了。用 oneinstack 自带的 vhost.sh 脚本生成的虚拟主机配置文件在 /usr/local/nginx/conf/vhost/ 目录下,自带的那个在 /usr/local/nginx/conf/nginx.conf 文件中间,全部 deny 掉就可以了。

sspanel 前端安装

利用 vhost.sh 添加一个虚拟主机,Rewrite rule 选 Laravel,根目录定到 /data/www/abc.dcc.com/public

cd /data/www/
sudo git clone -b new_master https://github.com/40huo/ss-panel-v3-mod.git abc.dcc.com
sudo chown -R username:username abc.dcc.com
sudo chmod -R 777 abc.dcc.com/storage
cd abc.dcc.com
php composer.phar install
cp config/.config.php.example .config.php

基础环境装好了,下面开始改配置,这就没什么难的了,按照默认的注释就好。

<?php

//  ss-panel v3 配置
//
// !!! 修改此key为随机字符串确保网站安全 !!!
$System_Config['key'] = '';
$System_Config['debug'] =  'false';  //  正式环境请确保为false
$System_Config['appName'] = '';             //站点名称
$System_Config['baseUrl'] = 'https://zhaojin97.cn';            // 站点地址
$System_Config['timeZone'] = 'PRC';        // PRC 天朝时间  UTC 格林时间
$System_Config['pwdMethod'] = 'sha256';       // 密码加密   可选 md5,sha256
$System_Config['salt'] = '';               // 密码加密用,从旧版升级请留空
$System_Config['theme']    = 'material';   // 主题
$System_Config['authDriver'] = 'cookie';   // 登录验证存储方式 可选: cookie,redis
$System_Config['sessionDriver'] = 'cookie';
$System_Config['cacheDriver'] = 'cookie';
$System_Config['tokenDriver'] = 'db';

//$System_Config['version'] = '<a href="https://www.zhaoj.in">Glzjin</a> mod-2016042210000';

// mu key 用于校验ss-go mu的请求,半角逗号分隔
$System_Config['muKey'] = '';
// 邮件
$System_Config['mailDriver'] = 'mailgun';   // mailgun or smtp or sendgrid

// 用户签到设置
$System_Config['checkinMin'] = '1989';       // 签到最少流量 单位MB
$System_Config['checkinMax'] = '8964';       // 签到最多流量

//
$System_Config['defaultTraffic'] = '100';      // 用户初始流量 单位GB

// 注册后获得的邀请码数量
$System_Config['inviteNum'] = '0';

# database 数据库配置
$System_Config['db_driver'] = 'mysql';
$System_Config['db_host'] = 'localhost';
$System_Config['db_database'] = '';
$System_Config['db_username'] = '';
$System_Config['db_password'] = '';
$System_Config['db_charset'] = 'utf8';
$System_Config['db_collation'] = 'utf8_general_ci';
$System_Config['db_prefix'] = '';

# redis
$System_Config['redis_scheme'] = 'tcp';
$System_Config['redis_host'] = '127.0.0.1';
$System_Config['redis_port'] = '6379';
$System_Config['redis_database'] = '0';
$System_Config['redis_password']="";

# mailgun
$System_Config['mailgun_key'] = '';
$System_Config['mailgun_domain'] = '';
$System_Config['mailgun_sender'] = '';

# smtp
$System_Config['smtp_host'] = '';
$System_Config['smtp_username'] = '';
$System_Config['smtp_port'] = '25';
$System_Config['smtp_name'] = '';
$System_Config['smtp_sender'] = '';
$System_Config['smtp_passsword'] = '';
$System_Config['smtp_ssl'] = 'false';

# aws
$System_Config['aws_access_key_id'] = '';
$System_Config['aws_secret_access_key'] = '';


#glzjin's time

#功能开关
$System_Config['enable_wecenter']='false';
$System_Config['enable_radius']='false';
$System_Config['enable_cloudxns']='false';
$System_Config['enable_duoshuo']='false';




#用户过期时间,在注册时设置。(天)
$System_Config['user_expire_in_default']='99999';

#Radius数据库设置
$System_Config['radius_db_host']='';
$System_Config['radius_db_database']='';
$System_Config['radius_db_user']='';
$System_Config['radius_db_password']='';

#Radius连接密钥
$System_Config['radius_secret']='';




#多说设置
$System_Config['duoshuo_shortname']="";
$System_Config['duoshuo_apptoken']="";


#节点离线设置
$System_Config['node_offline_warn']='true';

#异地登陆提示
$System_Config['login_warn']='true';

#端口池
$System_Config['min_port']='10000';
$System_Config['max_port']='65535';

#两种方式相对于ss端口的偏移
$System_Config['pacp_offset']='-20000';
$System_Config['pacpp_offset']='-20000';

#测速周期/h
$System_Config['Speedtest_duration']='6';


#随机分组,注册时随机分配到的分组,多个分组请用英文半角逗号分隔。
$System_Config['ramdom_group']='0';

#Wecenter 数据库信息
$System_Config['wecenter_db_host']='localhost';
$System_Config['wecenter_db_database']='';
$System_Config['wecenter_db_user']='';
$System_Config['wecenter_db_password']='';

#系统根域名 zhaoj.in 这样
$System_Config['wecenter_system_main_domain']='';

#访问路径,不开启这个功能的话就清空这个设置项吧
$System_Config['wecenter_url']='http://help.';

#可从安装好的 wecenter 目录下的 system/config.inc.php 得到

#G_COOKIE_PREFIX
$System_Config['wecenter_cookie_prefix']='mmg_';

#G_COOKIE_HASH_KEY
$System_Config['wecenter_cookie_key']='';

#充值返利百分比
$System_Config['code_payback']='20';

#注册时的流量重置日以及需要重置的流量,0不重置
$System_Config['reg_auto_reset_day']='0';
$System_Config['reg_auto_reset_bandwidth']='100';

#Cloudxns
$System_Config['cloudxns_apikey']='';#自己去 cloudxns.net 申请
$System_Config['cloudxns_apisecret']='';
$System_Config['cloudxns_domain']='zhaoj.in';#你的域名



#自动备份设置
$System_Config['enable_auto_backup']='false';
$System_Config['auto_backup_email']='your email';
$System_Config['auto_backup_webroot']='your base dir ,such as /home/wwwroot/ss.panel/';
$System_Config['auto_backup_passwd']='zip password';


#跳转延时,ms
$System_Config['jump_delay']='1800';



#是否启用邀请码注册
$System_Config['enable_invite_code']='true';

#是否启用邮箱验证码
$System_Config['enable_email_verify']='true';

#邮箱验证码有效期
$System_Config['email_verify_ttl']='3600';

#单IP可请求验证码次数(上面那个周期内)
$System_Config['email_verify_iplimit']='10';


#注册时默认加密方式
$System_Config['reg_method']='rc4-md5';

#注册时默认协议
$System_Config['reg_protocol']='origin';

#注册时默认协议参数
$System_Config['reg_protocol_param']='';

#注册时默认混淆方式
$System_Config['reg_obfs']='plain';

#注册时默认混淆参数
$System_Config['reg_obfs_param']='';

#注册时默认禁止访问IP列表,半角英文逗号分割
$System_Config['reg_forbidden_ip']='127.0.0.0/8,::1/128';

#注册时默认禁止访问端口列表,半角英文逗号分割,支持端口段
$System_Config['reg_forbidden_port']='';

#是否将登陆线程和IP绑定
$System_Config['enable_login_bind_ip']='true';



#等级到期时是否重置流量
$System_Config['enable_class_expire_reset']='true';

#等级到期时重置为的流量值,GB
$System_Config['enable_class_expire_reset_traffic']='0';

#账户到期时是否重置流量
$System_Config['enable_account_expire_reset']='true';

#账户到期时重置为的流量值,GB
$System_Config['enable_account_expire_reset_traffic']='0';

#购买时是否重置流量
$System_Config['enable_bought_reset']='true';

#账户到期之后是否会删除账户
$System_Config['enable_account_expire_delete']='true';

#账户到期几天之后会删除账户
$System_Config['enable_account_expire_delete_days']='0';

#验证码相关设置,自己去 Geetest.com 申请
$System_Config['geetest_id']='';
$System_Config['geetest_key']='';

#启用注册验证码
$System_Config['enable_geetest_reg']='false';

#启用登录验证码
$System_Config['enable_geetest_login']='false';

#启用签到验证码
$System_Config['enable_geetest_checkin']='false';

#自动清理多少天没签到的0级用户
$System_Config['enable_auto_clean_uncheck']='false';
$System_Config['enable_auto_clean_uncheck_days']='7';


#自动清理多少天没使用的0级用户
$System_Config['enable_auto_clean_unused']='false';
$System_Config['enable_auto_clean_unused_days']='30';


#是否夹带统计代码,自己在 resources/views/{主题名} 下创建一个 analytics.tpl ,如果有必要就用 literal 界定符
$System_Config['enable_analytics_code']='false';

#是否启用捐赠相关功能
$System_Config['enable_donate']='true';

#telegram bot,是否启用
$System_Config['enable_telegram']='false';

#telegram bot,bot 的 token ,跟 father bot 申请
$System_Config['telegram_token']='';

#telegram bot,群组会话 ID,把机器人拉进群里之后跟他 /ping 一下即可得到。
$System_Config['telegram_chatid']='';

#多用户混淆参数后缀
$System_Config['mu_suffix']='baidu.com';

#多用户混淆参数表达式,%5m代表取用户特征 md5 的前五位,%id 代表用户id,%suffix 代表上面这个后缀。
$System_Config['mu_regex']='%5m%id.%suffix';


#图灵机器人
$System_Config['enable_tuling']='false';
$System_Config['tuling_apikey']='';
$System_Config['tuling_apisecert']='';

#Telegram 机器人账号
$System_Config['telegram_bot']='_bot';

#Telegram 机器人在群组中不回应
$System_Config['telegram_group_quiet']='false';

#二维码解码方式,online,phpzbar,zxing_online,zxing_local
$System_Config['telegram_qrcode']='zxing_local';

#Telegram 机器人请求Key,随意设置,由大小写英文和数字组成,复杂一些,用于校验请求,更新这个参数之后请 php xcat setTelegram
$System_Config['telegram_request_token']='sjhueAMAndnenw2k2k1mmsJSJWMWiwiwthgfhgfh';

# sendgrid
$System_Config['sendgrid_key'] = '';
$System_Config['sendgrid_sender'] = '';


#支付系统

#取值 paymentwall,zfbjk,spay,none
$System_Config['payment_system']='none';

#PaymentWall
$System_Config['pmw_publickey']='';
$System_Config['pmw_privatekey']='';
$System_Config['pmw_widget']='m2_1';
$System_Config['pmw_height']='350px';

#alipay,spay
$System_Config['alipay_id']='';
$System_Config['alipay_key']='';

#alipay,zfbjk.com
$System_Config['zfbjk_pid']='';
$System_Config['zfbjk_key']='';
$System_Config['zfbjk_qrcodeurl']='https://www.zhaojin97.cn/wp-content/uploads/2016/01/630c50ab52bc139b2a33af8cc64e47ad2016010111570425541.jpg';

#不安全中转模式,这个开启之后使用除了 auth_aes128_md5 或者 auth_aes128_sha1 以外的协议地用户也可以设置和使用中转,但是,强烈推荐不开启。
$System_Config['relay_insecure_mode']='false';

数据库初始化

新建一个数据库,前面在设置里已经写好了名字,同样新建一个用户,赋给该数据库权限,不要用 root。

mysql -udbusername -p
use sspanel;
source /data/www/abc.dcc.com/sql/glzjin_all.sql;

添加管理员与计划任务

添加管理员

php -n xcat createAdmin

记得最后按一下 y。。。

计划任务

有一些定时清除用户之类的任务需要定时执行,所以添加计划任务。

30 22 * * * php /home/wwwroot/ss.panel/xcat sendDiaryMail
0 0 * * * php -n /home/wwwroot/ss.panel/xcat dailyjob
*/1 * * * * php /home/wwwroot/ss.panel/xcat checkjob

# 财务报表
5 0 * * * php -n /网站目录/xcat sendFinanceMail_day
6 0 * * 0 php -n /网站目录/xcat sendFinanceMail_week
7 0 1 * * php -n /网站目录/xcat sendFinanceMail_month

# 被墙检测
*/1 * * * * php -n /网站目录/xcat detectGFW

第一个是发送使用流量邮件,不发可以不填,后两个是需要定时执行的。别的安装指导里还写了几个 sync 什么的,我看了看代码,那些都是用来和 radius VPN 同步用户数据的,不用 VPN 就可以不填。

处理权限

cd /var/www
sudo chown -R www:www abc.dcc.com
sudo chmod -R 755 abc.dcc.com

给的权限小一点,可能会有 bug,日后再看吧。

后端安装

作者推荐他自己改过的 SSR 后端

git clone -b manyuser https://github.com/esdeathlove/shadowsocks
pip install cymysql
cd shadowsocks
cp apiconfig.py userapiconfig.py
cp config.json user-config.json

编辑 userapiconfig.py

# Config
#节点ID
NODE_ID = 1
#自动化测速,为0不测试,此处以小时为单位,要和 ss-panel 设置的小时数一致
SPEEDTEST = 6
#云安全,自动上报与下载封禁IP,1为开启,0为关闭
CLOUDSAFE = 1
#自动封禁SS密码和加密方式错误的 IP,1为开启,0为关闭
ANTISSATTACK = 0
#是否接受上级下发的命令,如果你要用这个命令,请参考我之前写的东西,公钥放在目录下的 ssshell.asc
AUTOEXEC = 1

多端口单用户设置,看重大更新说明。
MU_SUFFIX = 'zhaoj.in'
多端口单用户设置,看重大更新说明。
MU_REGEX = '%5m%id.%suffix'

#不明觉厉
SERVER_PUB_ADDR = '127.0.0.1' # mujson_mgr need this to generate ssr link
#访问面板方式
`API_INTERFACE = 'glzjinmod' #glzjinmod (数据库方式连接),modwebapi (http api)
#mudb,不要管
MUDB_FILE = 'mudb.json'
# HTTP API 的相关信息,看重大更新说明。
WEBAPI_URL = 'https://zhaoj.in'
WEBAPI_TOKEN = 'glzjin'

# Mysql 数据库连接信息
MYSQL_HOST = '127.0.0.1'
MYSQL_PORT = 3306
MYSQL_USER = 'ss'
MYSQL_PASS = 'ss'
MYSQL_DB = 'shadowsocks'
# 是否启用SSL连接,0为关,1为开
MYSQL_SSL_ENABLE = 0
# 客户端证书目录,请看 https://github.com/glzjin/shadowsocks/wiki/Mysql-SSL%E9%85%8D%E7%BD%AE
MYSQL_SSL_CERT = '/root/shadowsocks/client-cert.pem'
MYSQL_SSL_KEY = '/root/shadowsocks/client-key.pem'
MYSQL_SSL_CA = '/root/shadowsocks/ca.pem'

# API,不用管
API_HOST = '127.0.0.1'
API_PORT = 80
API_PATH = '/mu/v2/'
API_TOKEN = 'abcdef'
API_UPDATE_TIME = 60

# Manager 不用管
MANAGE_PASS = 'ss233333333'
#if you want manage in other server you should set this value to global ip
MANAGE_BIND_IP = '127.0.0.1'
#make sure this port is idle
MANAGE_PORT = 23333
#安全设置,限制在线 IP 数所需,下面这个参数随机设置,并且所有节点需要保持一致。
IP_MD5_SALT = 'randomforsafety'

运行的方式和 SSR 一样。

python server.py  # 用于调试
sudo ./logrun.sh  # 带日志后台运行
sudo ./run.sh # 不带日志后台运行

配置 Supervisor。

apt install supervisor

cat > /etc/supervisor/conf.d/ssr.conf << EOF
[program:ssr]
directory=/root/shadowsocks/
command=python server.py
stdout_logfile=/root/shadowsocks/ssserver.log
stderr_logfile=/root/shadowsocks/ssserver.log
autostart=true
autorestart=true
EOF

supervisorctl start ssr

服务器的性能优化可以参考我之前写过的 文章,简单的可运行下面的命令。

cat >> /etc/security/limits.conf << EOF
* soft nofile 51200
* hard nofile 51200
EOF
ulimit -n 51200
cat >> /etc/sysctl.conf << EOF
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr

fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
EOF
sysctl -p

Docker 版后端安装

docker version > /dev/null || curl -fsSL get.docker.com | bash
service docker restart

docker run -d --name=ssrmu -e NODE_ID=node_id -e API_INTERFACE=modwebapi -e WEBAPI_URL=panel_address -e WEBAPI_TOKEN=webapi_token -e MU_SUFFIX=your_mu_suffix --network=host --log-opt max-size=50m --log-opt max-file=3 --restart=always fanvinga/docker-ssrmu

增加国内中转节点

校内的网实在是太烂,UDP 连阿里云的梯子都连不上,没办法给 CSGO 加速,只好在国内的另一台 VPS 上也搭一个后端,配好节点,这里在后端的数据库那里,HOST 写前端的服务器地址,前端的数据库那里也要相应新建一个用户并赋权限。

跑起来以后,在前端增加一个节点,类型选择 Shadowsocks 中转,之后就可以在中转规则那里自行设置了。

搞定后用 Sockscap64 代理游戏进行加速。

Last Modified: September 12, 2018
Archives QR Code
QR Code for this page
Tipping QR Code
Leave a Comment

15 Comments
  1. 啦啦啦 啦啦啦

    大佬那个发送使用流量邮件的任务怎么关闭啊

    1. @啦啦啦定时任务里把那个dailymail的去掉就行了

  2. 奥奥 奥奥

    大佬 验证码geetest这个开启会出现500错误,请问有什么具体解决方案么?

    1. @奥奥没遇到过。。

  3. 老哥,这个中转应该怎么设置???
    比如我中转起点是杭州,目的地是洛杉矶,端口是2333,在客户端ip和密码之类的咋填写?
    希望能回复一下,谢谢

    1. @John我想复杂了,因为中转节点和目的节点配置完全一样刚才有点迷,,,看到效果了。。。谢谢

  4. 333 333

    方便联系下么?
    中转究竟是怎么配置的?

    1. 333 333

      @333兄弟,能把最后中转那一段具体一点吗??谢谢

    2. @333测试中转并不能转发UDP,只支持TCP

    3. @333配置就是选一个节点,把类型从Shadowsocks改成Shadowsocks中转,然后在用户界面有个中转规则,新建一个就好了,从中转节点到目的节点

  5. Geek Geek

    大佬,我刚装sspanel前端的时候没添加ssl证书,后来用宝塔面板里边的证书添加到服务器之后选择的强制https ,节点全挂了,对接新的节点用https开头对接不上,只剩和前端在同一服务器下的节点可用,后来对接节点不能使用https对接,把ssl关掉用http开头才可以,这是什么情况,可否指条明路,着急,老铁帮帮忙~

    1. ops ops

      @Geek最简单的办法就是直接重新对节点啊,按理说应该只需要修改节点配置文件就OK

  6. 俊俊 俊俊

    都看不懂~刚接触~

  7. ivanl ivanl

    那个节点加速的倍速现在显示是1倍速,怎么提升倍速?谢谢

    1. @ivanl后台节点设置里可以改