Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trojan多节点负载均衡 #19

Open
jamesBan opened this issue Feb 25, 2020 · 0 comments
Open

trojan多节点负载均衡 #19

jamesBan opened this issue Feb 25, 2020 · 0 comments
Labels

Comments

@jamesBan
Copy link
Owner

jamesBan commented Feb 25, 2020

准备工作

1、修改配置文件

#cp config.json config1.json
#vim config.json
....
local_port:1081
....

#vim config1.json
....
local_port:1082
....

2、启动多个客户端

  • 测试配置文件是否合法
#./trojan -c config.json -t
#./trojan -c config1.json -t
  • 启动
#./trojan -c config.json &
#lsof -i:1081

#./trojan -c config1.json &
#lsof -i:1082

也可以通过 supervisor 启动多个客户端

负载均衡

1、nginx方式

#vim nginx.conf

#和http同等级
stream {
	upstream trojan {
		server 127.0.0.1:1081 max_fails=5 fail_timeout=5s;
		server 127.0.0.1:1082 max_fails=5 fail_timeout=5s;
	}
	
	server {
		  listen 127.0.0.1:1080;
		  proxy_pass trojan;
	}
}

#nginx -t
#nginx -s reload

2、cow方式

  • install
#curl -L git.io/cow | bash
  • config
#vim ~/cow/rc
...
listen = http://127.0.0.1:1080

# SOCKS5 二级代理
proxy = socks5://127.0.0.1:1081
proxy = socks5://127.0.0.1:1082
....
  • start
  cow &

后记

无论是通过那种方式最终都是通过127.0.0.1:1080进行代理

@jamesBan jamesBan added the nginx label Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant