  
TA的每日心情 | 郁闷 前天 00:24 |
---|
签到天数: 1669 天 [LV.Master]伴坛终老
|
今天搭建了个nginx+keepalived双主负载均衡,在怎么让前端两台nginx+keepalived通信上,让我纠结了半天,机房前面有没有硬件防火墙不得知,所以为了安全我决定还是把iptables启动起来,下面就是我启动了iptables,并且还能让nginx+keepalived双主都通信的配置文件.
系统:centos 5.9 64位
环境:nginx+keeplived双主负载均衡
1.先确认服务器是否有安装iptables
rpm -qa|grep iptables
2.做好nginx+keeplived双主负载均衡
这个大家可以网上去找,有很多的配置文档的.
3.修改iptables配置文件,并启动
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -d 192.168.10.200 -j ACCEPT
-A INPUT -d 192.168.10.201 -j ACCEPT
-A INPUT -p vrrp -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
这里说明下,ip:192.168.10.200和192.168.10.201是vip,即虚拟ip地址,也就是给外网访问用的.
保存配置文件后,重启iptables
service iptables restart
4.查看两台nginx+keepalived通信是否有问题
ip add
tail -n 100 /var/log/message
这里我就不给大家截图了,因为都是线上环境,为了安全,你们懂的.
|
|