成长值: 195 签到天数: 4690 天
[LV.Master]伴坛终老
发表于 2016/12/26 19:51
|
显示全部楼层
| 阅读模式
| Google Chrome 55.0.2883.87
| Windows 10
移动到阿里云香港只有1MB/S,用国内深圳阿里云BGP转发下,速度瞬间飞起来。
此方法,只要是TCP的都能用,什么MC游戏啊,视频直播都可以。
阿里云购买:https://www.aliyun.com/product/swas?userCode=kj5ig4dp
centos 6 x64运行此命令安装
输入rpm -qi haproxy可以看到版本号是1.5.4,如果不满意可以自己去官网编译安装
[root@pac haproxy]# rpm -qi haproxy
Name : haproxy Relocations: (not relocatable)
Version : 1.5.4 Vendor: CentOS
Release : 3.el6 Build Date: Tue 10 May 2016 07:17:37 PM UTC
Install Date: Mon 26 Dec 2016 11:29:07 AM UTC Build Host: worker1.bsys.centos.org
Group : System Environment/Daemons Source RPM: haproxy-1.5.4-3.el6.src.rpm
Size : 2552550 License: GPLv2+
Signature : RSA/SHA1, Thu 12 May 2016 10:49:33 AM UTC, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org >
URL : http://www.haproxy.org/
Summary : HAProxy is a TCP/HTTP reverse proxy for high availability environments
Description :
HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high
availability environments. Indeed, it can:
- route HTTP requests depending on statically assigned cookies
- spread load among several servers while assuring server persistence
through the use of HTTP cookies
- switch to backup servers in the event a main one fails
- accept connections to special ports dedicated to service monitoring
- stop accepting connections without breaking existing ones
- add, modify, and delete HTTP headers in both directions
- block requests matching particular patterns
- persists clients to the correct application server depending on
application cookies
- report detailed status as HTML pages to authenticated users from a URI
intercepted from the application
输入rpm -ql haproxy可以看到当然的软件文件占用
[root@pac haproxy]# rpm -ql haproxy
/etc/haproxy
/etc/haproxy/haproxy.cfg
/etc/logrotate.d/haproxy
/etc/rc.d/init.d/haproxy
/etc/sysconfig/haproxy
/usr/bin/halog
/usr/bin/iprange
/usr/sbin/haproxy
/usr/share/doc/haproxy-1.5.4
/usr/share/doc/haproxy-1.5.4/CHANGELOG
/usr/share/doc/haproxy-1.5.4/LICENSE
/usr/share/doc/haproxy-1.5.4/README
/usr/share/doc/haproxy-1.5.4/acl-content-sw.cfg
/usr/share/doc/haproxy-1.5.4/acl.fig
/usr/share/doc/haproxy-1.5.4/architecture.txt
/usr/share/doc/haproxy-1.5.4/close-options.txt
/usr/share/doc/haproxy-1.5.4/coding-style.txt
/usr/share/doc/haproxy-1.5.4/configuration.txt
/usr/share/doc/haproxy-1.5.4/content-sw-sample.cfg
/usr/share/doc/haproxy-1.5.4/cookie-options.txt
/usr/share/doc/haproxy-1.5.4/cttproxy-src.cfg
/usr/share/doc/haproxy-1.5.4/design-thoughts
/usr/share/doc/haproxy-1.5.4/design-thoughts/backends-v0.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/backends.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/be-fe-changes.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/binding-possibilities.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/buffer-redesign.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/buffers.fig
/usr/share/doc/haproxy-1.5.4/design-thoughts/config-language.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/connection-reuse.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/cttproxy-changes.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/entities-v2.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/how-it-works.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/http_load_time.url
/usr/share/doc/haproxy-1.5.4/design-thoughts/rate-shaping.txt
/usr/share/doc/haproxy-1.5.4/design-thoughts/sess_par_sec.txt
/usr/share/doc/haproxy-1.5.4/gpl.txt
/usr/share/doc/haproxy-1.5.4/haproxy-en.txt
/usr/share/doc/haproxy-1.5.4/haproxy-fr.txt
/usr/share/doc/haproxy-1.5.4/haproxy.1
/usr/share/doc/haproxy-1.5.4/haproxy.cfg
/usr/share/doc/haproxy-1.5.4/internals
/usr/share/doc/haproxy-1.5.4/internals/acl.txt
/usr/share/doc/haproxy-1.5.4/internals/body-parsing.txt
/usr/share/doc/haproxy-1.5.4/internals/buffer-operations.txt
/usr/share/doc/haproxy-1.5.4/internals/buffer-ops.fig
/usr/share/doc/haproxy-1.5.4/internals/connect-status.txt
/usr/share/doc/haproxy-1.5.4/internals/connection-header.txt
/usr/share/doc/haproxy-1.5.4/internals/connection-scale.txt
/usr/share/doc/haproxy-1.5.4/internals/entities.fig
/usr/share/doc/haproxy-1.5.4/internals/entities.pdf
/usr/share/doc/haproxy-1.5.4/internals/entities.svg
/usr/share/doc/haproxy-1.5.4/internals/entities.txt
/usr/share/doc/haproxy-1.5.4/internals/hashing.txt
/usr/share/doc/haproxy-1.5.4/internals/header-parser-speed.txt
/usr/share/doc/haproxy-1.5.4/internals/header-tree.txt
/usr/share/doc/haproxy-1.5.4/internals/http-cookies.txt
/usr/share/doc/haproxy-1.5.4/internals/http-docs.txt
/usr/share/doc/haproxy-1.5.4/internals/http-parsing.txt
/usr/share/doc/haproxy-1.5.4/internals/naming.txt
/usr/share/doc/haproxy-1.5.4/internals/pattern.dia
/usr/share/doc/haproxy-1.5.4/internals/pattern.pdf
/usr/share/doc/haproxy-1.5.4/internals/polling-states.fig
/usr/share/doc/haproxy-1.5.4/internals/repartition-be-fe-fi.txt
/usr/share/doc/haproxy-1.5.4/internals/sequence.fig
/usr/share/doc/haproxy-1.5.4/internals/stats-v2.txt
/usr/share/doc/haproxy-1.5.4/internals/stream-sock-states.fig
/usr/share/doc/haproxy-1.5.4/internals/todo.cttproxy
/usr/share/doc/haproxy-1.5.4/lgpl.txt
/usr/share/doc/haproxy-1.5.4/proxy-protocol.txt
/usr/share/doc/haproxy-1.5.4/queuing.fig
/usr/share/doc/haproxy-1.5.4/tarpit.cfg
/usr/share/doc/haproxy-1.5.4/url-switching.cfg
/usr/share/haproxy
/usr/share/haproxy/400.http
/usr/share/haproxy/403.http
/usr/share/haproxy/408.http
/usr/share/haproxy/500.http
/usr/share/haproxy/502.http
/usr/share/haproxy/503.http
/usr/share/haproxy/504.http
/usr/share/haproxy/README
/usr/share/man/man1/halog.1.gz
/usr/share/man/man1/haproxy.1.gz
/var/lib/haproxy
[root@pac haproxy]#
修改配置文件vi /etc/haproxy/haproxy.cfg
global
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 65535
user haproxy
group haproxy
daemon
defaults
mode tcp
log global
option dontlognull
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
maxconn 65535
frontend ss-in *:端口 ##阿里云深圳中转服务器本地使用端口port自己改
default_backend ss-out
backend ss-out
balance roundrobin ##阿里云香港源服务器多个后端轮循
server app1 ip:端口 check ##阿里云香港源服务器 IP 和 SS 端口port自己改1号服务器
server app2 ip:端口 check ##阿里云香港源服务器 IP 和 SS 端口port自己改2号服务器,如果没有多台服务器则删除不写此行 复制代码
启动
开机自动启动
chkconfig --level 2345 haproxy on
复制代码
如果要多端口用户,做不同的东西,比如说同时使用MC,就可以在配置文件最下方增加
frontend mc-in *:端口
default_backend mc-out
backend mc-out
server app1 ip:端口 复制代码
然后重启服务即可
查看进程端口占用情况
netstat -apn | grep haproxy
复制代码