基于apache的反向代理和负载均衡

这个是apache2.2以后增加的新的特性。

首先我们这边有2个域名。一个是www.timo.com还有一个是mail.timo.com这两个域名。同时www.zauc.com内网有2台机器 (192.168.0.10和192.168.0.11),当然也可以是外网.mail.zauc.com这个域名的内网IP为 (192.168.0.20)

要使用proxy和blance一定要在编译的时候加入proxy和blance.

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-modules=all --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-vhost-alias
make
make install

安装完成后在extra/httpd-vhosts.conf中进行如下配置。

    ServerAdmin timo@timo.com
    ServerName www.timo.com
    ProxyPass / balancer://www.timo.com/
    ErrorLog "logs/www.timo.com-error_log"
    CustomLog "logs/www.timo.com-access_log" common

   ServerAdmin timo@timo.com
    ServerName mail.timo.com
    ProxyPass / http://192.168.0.20/
    ProxyPassReverse / http://192.168.0.20/
    ErrorLog "logs/mail.timo.com-error_log"
    CustomLog "logs/mail.timo.com-access_log" common

而www.timo.com还需要在httpd.conf进行配置

ProxyRequests Off

    BalancerMember http://192.168.0.10 loadfactor=1<br />
    BalancerMember http://192.168.0.11 loadfactor=1

这里只是简单的一个配置。详细的可以参考下apache2.2中文文档中的说明

关于 Timo
XNIX SA & MYSQL DBA

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: