Configure reverse proxy and load balancer configuration on Apache

Source: Internet
Author: User

Before a project needs to configure load balancing on Apache, because of the variety of things, time is tight, there is no time to get.

Today, the time to test a piece, at least can be a proxy.

You will now configure how the reverse proxy and load balancer are described separately.

1. Reverse Proxy

Steps:

(1) Open the reverse proxy module in Apache configuration file httpd.conf

#-----------------------------------------------

LoadModule Proxy_module modules/mod_proxy.so

LoadModule Proxy_connect_module

#-----------------------------------------------

(2) Add the following on the last side of the httpd.conf

#-----------------------------------------------

Namevirtualhost 10.0.0.1

<virtualhost 10.0.0.1>

ServerName www.baidu.com

Errorlog Logs/iis.log

Customlog Logs/iis.access.log Common

Proxypass/http://www.baidu.com

Proxypassreverse/http://www.baidu.com

</VirtualHost>

#-----------------------------------------------

(3) Enter HTTP://10.0.0.1/in the browser, you will find that the content of the page display is already http://www.baidu.com content.



2. Load Balancing

Steps:

(1) Open the reverse proxy module in Apache configuration file httpd.conf

#-----------------------------------------------

LoadModule Proxy_module modules/mod_proxy.so

LoadModule Proxy_connect_module

LoadModule Proxy_balancer_module modules/mod_proxy_balancer.so

#-----------------------------------------------

(2) Add the following on the last side of the httpd.conf

#-----------------------------------------------

Proxyrequests OFF

<proxy balancer://fzjh>

#loadfactor值越大, the greater the chance of being assigned.

Balancermember http://www.baidu.com loadfactor=2

Balancermember http://www.360.com loadfactor=1

Balancermember http://www.sina.com loadfactor=2

</Proxy>

Namevirtualhost 172.16.0.1

<virtualhost 172.16.0.1>

ServerName 172.16.0.1

#这个是根据流量来进行分发,

#ProxyPass/balancer://fzjh/lbmethod=bytraffic

proxypass/balancer://fzjh/

proxypassreverse/balancer://fzjh/

#ProxyPreserveHost on

</VirtualHost>

#-----------------------------------------------

(3) Enter the HTTP://172.16.0.1/in the browser, you will find that it will be assigned to baidu,360 or Sina according to the configuration situation.


Configure reverse proxy and load balancer configuration on Apache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.