在CentOS中安装XX Net - shxdev/install-xxnet GitHub Wiki

XX-Net部署手册 for CentOS

1. 创建操作用户并设置sudo权限(如已有非root用户请从第2步开始)

# useradd -d /home/op op
# passwd op

# chmod +w /etc/sudoers
# vi /etc/sudoers

	## Allow root to run any commands anywhere
	root    ALL=(ALL)       ALL
	op      ALL=(ALL)       ALL

	Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/:/usr/local/sbin/

# chmod -w /etc/sudoers

2.退出后使用op用户登录

$ mkdir ~/setup
$ cd ~/setup

3.安装必要软件库

$ sudo yum install -y gcc gcc-c++ autoconf automake wget openssl openssl-devel pcre pcre-devel

4.下载软件

$ curl https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz > Python-2.7.14.tgz && curl https://codeload.github.com/XX-net/XX-Net/zip/3.11.3 > xx-net-3.11.3.zip && wget https://bootstrap.pypa.io/get-pip.py && curl http://nginx.org/download/nginx-1.13.10.tar.gz > nginx-1.13.10.tar.gz

5.安装Python2.7

$ cd ~/setup
$ tar -xzvf Python-2.7.14.tgz
$ vi Python-2.7.14/Modules/Setup.dist
	(取消下面几行的注释)
	_socket socketmodule.c timemodule.c

	_ssl _ssl.c \
	        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
	        -L$(SSL)/lib -lssl -lcrypto

$ cd Python-2.7.14
$ ./configure --prefix=/usr/local
$ make && sudo make install
$ sudo mv -f /usr/bin/python /usr/bin/python2.6
$ sudo ln -s /usr/local/bin/python2.7 /usr/bin/python
$ sudo vi /usr/bin/yum
	(将首行的#!/usr/bin/python改为#!/usr/bin/python2.6)

5.安装pip

$ cd ~/setup
$ sudo python get-pip.py

6.安装XX-Net

$ sudo pip install pyOpenSSL
$ cd ~/setup/
$ unzip -x xx-net-3.11.3.zip
$ cd XX-Net-3.11.3
$ sudo ./xx_net.sh
$ sudo vi data/launcher/config.yaml
	(修改allow_remote_connect值为1)
	launcher: {allow_remote_connect: 1, control_port: 8085, last_run_version: 3.11.3,
$ sudo ./xx_net.sh restart
$ sudo service iptables stop

7.登录X-Tunnel

通过浏览器访问 "http://<ip>:8085"
左边菜单找到"X-TUNNEL->配置"
输入用户名口令进行登录

8.安装Nginx反向代理

$ cd ~/setup
$ tar -xzvf nginx-1.13.10.tar.gz
$ cd nginx-1.13.10
$ ./configure --with-stream --prefix=/usr/local
$ make && sudo make install
$ sudo vi /usr/local/conf/nginx.conf
	(在文件末尾“http域之外”,添加下列内容)
stream {
    upstream xxnet_socks {
        hash $remote_addr consistent;
        server 127.0.0.1:1080 weight=5 max_fails=3 fail_timeout=30s;
    }
    server {
        listen 1081;
       proxy_connect_timeout 1s;
       proxy_timeout 3s;
       proxy_pass xxnet_socks;
    }

}

$ sudo nginx

9.验证

$ curl -x socks5://<ip>:1081 www.google.com

(如果返回的HTML正常则表示链接成功)

10.修改防火墙策略 and 启动防火墙

$ sudo iptables -I INPUT -p tcp --dport 1081 -j ACCEPT
$ sudo /etc/rc.d/init.d/iptables save
$ sudo service iptables restart
⚠️ **GitHub.com Fallback** ⚠️