Chinaunix首页 | 论坛 | 博客
  • 博客访问: 241221
  • 博文数量: 36
  • 博客积分: 1495
  • 博客等级: 上尉
  • 技术积分: 412
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-09 13:34
文章分类

全部博文(36)

文章存档

2016年(1)

2015年(12)

2014年(2)

2012年(4)

2011年(1)

2009年(6)

2008年(10)

我的朋友

分类: 网络与安全

2014-09-24 09:21:11

前面的一篇文章写了在同一个网段的情况下的配置,那如果web Server 和HAPROXY 不在同一网段 甚至不在一个IDC内部的情况下怎么来解决这个问题呢
HAproxy 的配置和前面一样。如果是HAproxy 1.5-dev 版默认编译就行了,如果是1.5.3 编译的时候需要(make TARGET=linux2628 USE_LINUX_TPROXY=1)加上红色的部份。

操作步骤如果:
1.在HAproxy 和Web Server 之间要建一个隧道
HAproxy 配置:
iptunnel add tun0 mode gre remote web Server   local HAproxy  ttl 10 (红色的改成相对应的IP地址)
 ifconfig tun0 10.0.201.1/24
 ifconfig tun0 up
 ifconfig tun0 pointopoint 10.0.201.1

web Server 配置:
iptunnel add tun0 mode gre remote web Server   local HAproxy  ttl 10 (红色的改成相对应的IP地址)
 ifconfig tun0 10.0.201.1/24
 ifconfig tun0 up
 ifconfig tun0 pointopoint 10.0.201.1


2.在web Server 配置iptables 和策略路由

cat /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
100   haproxy

iptables -t mangle -A INPUT -d 10.0.201.2/32  -j MARK --set-mark 1
iptables -t mangle -A OUTPUT -s 10.0.201.2/32  -j MARK --set-mark 1
ip rule  add table haproxy   
ip rule add fwmark 0x1 table haproxy  (执行这个步骤后最好看一下规则表,以后发生中断连不上服务器的问题)
ip route add default via 10.0.201.1 dev tun0 src 10.0.201.2 table haproxy




阅读(1156) | 评论(0) | 转发(0) |
0

上一篇:haproxy 透明传输

下一篇:Haproxy 安装 起动

给主人留下些什么吧!~~