💗心爱的💗-小沨

  • 首页
  • 网盘
  • 图床
  • 赞助
  • 关于本站
私人小天地
谈天说地,学习笔记
  1. 首页
  2. Linux系统
  3. 正文

linux使用haproxy代理转发实现加速

2016年1月28日 7072点热度 0人点赞 2条评论

在美国VPS上搭建转发服务,加速服务器上搭建haproxy服务
使用原理: PC->加速服务器frontend->加速服务器backend->美国 VPS
1.安装haproxy:
centos:

yum install haproxy -y
注: 如果yum找不到haproxy的话, 需要下载执行一下:

#CentOS 5 – 32-bit
rpm -Uvh http://mirror.overthewire.com.au/pub/epel/5/i386/epel-release-5-4.noarch.rpm

#CentOS 5 – 64-bit
rpm -Uvh http://mirror.overthewire.com.au/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

#CentOS 6 – 32-bit
rpm -Uvh http://mirror.overthewire.com.au/pub/epel/6/i386/epel-release-6-8.noarch.rpm

#CentOS 6 – 64-bit
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

ubuntu

apt-get install haproxy

debian

先添加apt源
vi  /etc/apt/sources.list
然后添加源
deb http://ftp.us.debian.org/debian/ wheezy-backports main
保存后
apt-get update
然后安装haproxy
apt-get install haproxy

2.修改haproxy配置文件,使用脚本启动haproxy

vi /etc/default/haproxy

将该选项修改为1 ENABLED=1

3.修改配置文件

vi /etc/haproxy/haproxy.cfg

单户:

global
ulimit-n 51200
defaults
log global
mode tcp
option dontlognull
contimeout 1000
clitimeout 150000
srvtimeout 150000
frontend ss-in
bind *:8968
default_backend ss-out
backend ss-out
server server1 SS_IP:8968 maxconn 20480  #SS_IP是ss的ip,8968是SS的端口

多户或者均衡

global
ulimit-n  51200
defaults
log global
mode    tcp
option  dontlognull
timeout connect 1000ms
timeout client 150000ms
timeout server 150000ms
frontend 110-in
bind *:110
default_backend 110-out
frontend 109-in
bind *:109
default_backend 109-out
frontend 110-in-jp
bind *:1110
default_backend 110-out-jp
backend 110-out
server server1 spg.xx.xx:110 maxconn 20480
backend 109-out
server server1 spg.xx.xx:109 maxconn 20480
backend 110-out-jp
server server1 jp.xx.xx:110 maxconn 20480

可以配置多端口。
frontend的端口为要在中转服务器上用的端口
backend的端口是源服务器的ip和端口
每个端口的“frontend” 要对应一个“backend”
文件写的时候要记得一一对应。

4.启动服务,检查修改是否生效

service haproxy start

如果前面没设置开机启动,就运行一下:

update-rc.d haproxy defaults

关闭防火墙

sudo ufw disable

借鉴
http://blog.e9china.net/tufan/centos5liyonghaproxyshadowsockszhongzhuan.html
http://www.crazycen.com/internet/2225.html
https://smileawei.com/shadowsocks-haproxy/

标签: haproxy linux 转发
最后更新:2018年12月13日

mikj

这个人很懒,什么都没留下

打赏 点赞
< 上一篇
下一篇 >

文章评论

  • panzhc

    这样做的意义是什么呢?加速服务器上不能直接搭ss吗?

    2016年6月29日
    登录以回复
    • mikj

      @panzhc 加速服务器是在国内,搭建SS 没意义

      2016年6月29日
      登录以回复
  • 您需要 登录 之后才可以评论
    站内搜索
    联系我
    分类
    • AI智能
    • Android
    • Linux系统
    • VPS服务器
    • windows系统
    • wordpress
    • 域名相关
    • 建站分享
    • 教程学习
    • 数据库类
    • 旅行点滴
    • 未分类
    • 网络服务
    • 资源分享
    • 跨境出海
    • 金融投资
    友情链接
    • 麦麦同学
    • 陈否否
    • 朱志瑞
    • 傻子-跸西的blog
    • semnew
    • 轨迹博客
    • 撸羊毛
    • QQPCC
    • 天下无鱼
    • QQTM论坛
    • LINUX DO
    • 小沨记事本
    • 怪鸟博客
    • 我的图库
    • 夜狐
    • 李子博客
    • 光的魔术师
    • 我喔喔喔
    • Shucheng Li
    • 寥寥后花园
    • 爱购啦
    • vzone
    • 死老鬼
    • 豆博
    • 娃娃博客

    COPYRIGHT © 2025 Xinai.De. ALL RIGHTS RESERVED.@ 网站运行:@ 服务器运行状态

    Theme Kratos Made By Seaton Jiang