售前咨询
技术支持
渠道合作

ShadowSocks多用户管理系统搭建(moeSS+manyuser)

如果你的手上有多个墙外vps可以搭建一个Shadowsocks分享平台。前端面板(moeSS,建议使用ssl加密)和后端(shadowsocks-manyuser),教程如下:

1. Shadowsocks多用户前端moeSS安装

环境:CentOS-6.6-x86_64-minimal.iso

PHP环境配置

安装lnmp环境(必须安装Nginx、MySQL、PHP5.4+),参考《OneinStack》或者《lnmp一键安装包》

加虚拟主机ss.linuxeye.com,需要用到pathinfo,下面是我的配置文件(/usr/local/nginx/conf/vhost/ss.linuxeye.com.conf):

  1. server {
  2. listen 443 ssl spdy;
  3. ssl_certificate 1_ss.linuxeye.com_bundle.crt;
  4. ssl_certificate_key ss.linuxeye.com.key;
  5. ssl_ciphers “CHACHA20:GCM:HIGH:!DH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS”;
  6. ssl_session_cache shared:SSL:10m;
  7. ssl_session_timeout 10m;
  8. ssl_stapling on;
  9. ssl_stapling_verify on;
  10. resolver 8.8.8.8 8.8.4.4 valid=300s;
  11. resolver_timeout 5s;
  12. server_name ss.linuxeye.com;
  13. access_log off;
  14. index index.html index.htm index.jsp index.php;
  15. root /home/wwwroot/ss.linuxeye.com;
  16. if (!-e $request_filename) {
  17.         rewrite ^/(.*)$ /index.php/$1 last;
  18.         break;
  19.         }
  20. location ~ [^/]\.php(/|$) {
  21.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  22.         try_files $fastcgi_script_name =404;
  23.         set $path_info $fastcgi_path_info;
  24.         fastcgi_param PATH_INFO $path_info;
  25.         fastcgi_pass unix:/dev/shm/php-cgi.sock;
  26.         fastcgi_index index.php;
  27.         include fastcgi.conf;
  28.         }
  29. location ~ /\.ht {
  30.         deny  all;
  31.         }
  32. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
  33.         expires 30d;
  34.         }
  35. location ~ .*\.(js|css)?$ {
  36.         expires 7d;
  37.         }
  38. }
  39. server {
  40. listen 80;
  41. server_name ss.linuxeye.com;
  42. rewrite ^(.*)$ https://$host$1 permanent;
  43. }

下载代码

  1. cd ~/oneinstack/src
  2. git clone https://github.com/monoking/moeSS.git #下载moeSS
  3. mv moeSS/* /home/wwwroot/ss.linuxeye.com/ #将代码上传到知道虚拟主机(ss.linuxeye.com)网站根目录
  4. find /home/wwwroot/ss.linuxeye.com –type f –exec chmod 644 {} \;   #为了安全,将代码里面文件权限设置为644
  5. find /home/wwwroot/ss.linuxeye.com –type d –exec chmod 755 {} \;   #为了安全,将代码里面目录权限设置为755
  6. chown -R www.www /home/wwwroot/ss.linuxeye.com/  #修改代码用户和所在组设置为www

导入sql

  1. cd /home/wwwroot/ss.linuxeye.com/
  2. mysql -uroot -p
  3. mysql> create database shadowsocks;
  4. mysql> use shadowsocks;
  5. mysql> source shadowsocks.sql;
  6. //注:#创建moeSS面板和多用户后端shadowsocks-manyuser(shadowsocks-manyuser只需要连接user表,后面授权注意)连接数据库 mysql> grant all privileges on shadowsocks.user to ‘oneinstack_ss’@’%’ identified by ‘oneinstack_pwd’;
  7. mysql> flush privileges;

开启mysql远程连接端口

  1. iptables -I INPUT 5 -p tcp -m state –state NEW -m tcp –dport 3306 -j ACCEPT  #建议只对指定服务器开放3306端口
  2. service iptables save

修改moeSS配置文件

  1. # cd /home/wwwroot/ss.linuxeye.com/application/config
  2. # cp config-sample.php config.php  #直接复制模板,更改

修改如下几个参数:

    • SITE_NAME:显示在系统各处的网站名称;
    • base_url:网站地址。如果你的系统放在二级目录的话,请写全二级目录的地址,并且不要忘了后置的斜杠和前置的 http:// 或 https://;
    • encryption_key:用来加密Cookie信息的,请随意写一串字符串作为加密密钥。务必修改该值,否则Cookie可以被轻易伪造!
  1. # cp database-simple.php database.php    #数据库连接文件

保证hostname, username, password, database 四项设置完全正确,否则可能会导致程序无法连接数据库。

登录管理后台

访问:https://ss.linuxeye.com/admin, 可以登录系统进行配置了。

默认情况下系统自带了用户名和密码为 admin/admin12345 的管理员账户和用户账户。你可以先尝试使用这个账户分别登陆用户面板和管理面板来确认网站是否安装成功。安装完成之后请务必修改默认密码,在管理面板的左下方,你可以找到系统设置->一般设置。其中包含了很多系统的基础设置。你可以选择使用默认值,也可以按照需要修改。

2. Shadowsocks多用户后端shadowsocks-manyuser

先安装需要的环境依赖

如果操作系统是Debian/Ubuntu:

  1. apt-get -y install python-pip python-m2crypto

CentOS:

  1. yum -y install m2crypto python-setuptools
  2. easy_install pip

安装cymysql

  1. pip install cymysql

安装shadowsocks-manyuser

  1. cd ~/oneinstack/src
  2. git clone -b manyuser https://github.com/mengskysama/shadowsocks.git

修改配置

vi ~/shadowsocks/shadowsocks/Config.py   #前端数据库连接信息

  1. #Config
  2. MYSQL_HOST = ‘ss.linuxeye.com’
  3. MYSQL_PORT = 3306
  4. MYSQL_USER = ‘oneinstack_ss’
  5. MYSQL_PASS = ‘oneinstack_pwd’
  6. MYSQL_DB = ‘shadowsocks’

关闭iptables

  1. service iptables stop   #shadowsocks多用户需要启用多个端口,添加iptables麻烦,关闭
  2. chkconfig iptables off

运行shadowsocks-manyuser

  1. nohup python server.py &

上一篇:

下一篇:

相关文章