Apache Load Balancing configuration (reverse proxy mode)

Source: Internet
Author: User

Apache Load Balancing configuration (reverse proxy mode)

This article is only suitable for EKP products, as the application cluster is the function of our own implementation, so the configuration here may be inconsistent with the configuration of other products.

We currently use Apache as a front-end load-balanced forwarder. Considering the instability of JK, we recommend using Agent mode to work together. Therefore, the installed Apache needs to have Proxy_module,proxy_ftp_module,proxy_http_module, Rewrite_module,proxy_connect_module, Proxy_ Balancer_module and Proxy_ajp_module modules.

The following is an example of configuring Apache with the Application "EKP" to illustrate how Apache can collaborate with app apps on two machines, IP "192.168.3.119" and "192.168.3.116". 1.1 confirm to open load Balancing module

Open the Apache installation directory/conf/httpd.conf file and open the module in the red box below, and if the line starts with the "#" sign, remove the "#" ("#"), the behavior comment line at the beginning of the following figure:

1.2 Add EKP Load Balancing configuration file

At the end of the httpd.conf file, add the configuration that references the EKP configuration file as follows:

# Virtual EKP host for balacing

Include conf/httpd-ekp-balance.conf

The new configuration in the configuration file is located in the following figure:

1.3 EKP Load Balancing configuration file Settings

Create a new file named "Httpd-ekp-balance.conf" in the Apache installation directory/conf directory, and add the following content to the file. The following is a complete cluster example setting for two EKP nodes, in general, as long as the replacement of the specific IP and related directory of the path to complete the configuration. If there are more than two nodes, add the Balancermember at the Proxy section and join the new node in the later Proxypassreverse section. The red section "M69" and "m115" in the following table need to be "Cluster.session.balancerRoute" with the parameters in each application ekp\web-inf\classes\trswcmcluster.properties file Remain consistent.

<virtualhost *:80>

AddType text/javascript. js

AddType text/css; CSS

AddType text/html;charset=utf-8. html

ServerName my.ekp.com

ServerAdmin wu.guowei@trs.com.cn

<proxy balancer://ekpcluster>

Balancermember http://192.9.200.69:8065 route=m69

Balancermember http://192.9.200.115:8060 route=m115

Proxyset Stickysession=csid

</Proxy>

Rewriteengine on

Rewriterule ^/ekp/(. *\. ( JSP|DO|JWS|APPLETDO) $ balancer://ekpcluster/ekp/$1 [p,l]

Rewriterule ^/ekp/(. *;jsessionid.*) $ balancer://ekpcluster/ekp/$1 [p,l]

Rewriterule ^/ekp/(SD) $ balancer://ekpcluster/ekp/$1 [p,l]

Rewriterule ^/ekp/(trsidsssoproxyservlet) $ balancer://ekpcluster/ekp/$1 [p,l]

#SoapService rule

Rewriterule ^/ekp/services/(. *) http://192.9.200.69:8065/ekp/services/$1 [p,l]

proxypassreverse/http://192.9.200.69:8065/

proxypassreverse/http://192.9.200.115:8060/

#webpic

Alias/webpic "Z:/wcmdata/webpic"

<directory "Z:/wcmdata/webpic" >

Options-indexes multiviews followsymlinks Includes

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

<directory "D:/trs/trsekpv65_cluster_b1111/wcmdata/webpic/web-inf" >

Deny from all

</Directory>

#ekp

ALIAS/EKP "D:/TRS/TRSEKPV65_CLUSTER_B1111/TOMCAT/WEBAPPS/EKP"

<directory "D:/TRS/TRSEKPV65_CLUSTER_B1111/TOMCAT/WEBAPPS/EKP" >

Options-indexes multiviews followsymlinks Includes

DirectoryIndex index.html

AllowOverride None

Order Allow,deny

Allow from all

</Directory>

<directory "D:/trs/trsekpv65_cluster_b1111/tomcat/webapps/ekp/web-inf" >

Deny from all

</Directory>

<Location/ekpcluster-manager>

SetHandler Balancer-manager

#Deny from all

#设定可以访问管理器的主机

Allow from all

</Location>

</VirtualHost>

 

Attention Matters

L Route and Stickysession

Session fixing is an important function of the load balancer, which is to fix the user session on a service node and forward the session to the other node processing only if the node fails. The settings for these two items are also related to the EKP settings, which are mentioned below.

L The Rewriterule in the config file should be on one line

Some of the wrapping in the example may be required for document typesetting, and be aware that each rewriterule is one line when you actually set it up.

L Share Directory Address

if the primary node and Apache are configured on the same machine, the shared directory address suggests using the installed Wcmdata address directly. 1.4 EKP Load Balancing configuration main configuration instructions

httpd-ekp-balance.conf main configuration instructions are as follows:

#section 1 Set Load Balancing members

<proxy balancer://ekpcluster>

Balancermember http://192.9.200.69:8065 route=m69

Balancermember http://192.9.200.115:8060 route=m115

Proxyset Stickysession=csid

</Proxy>

#section 2 To set forwarding rules, only dynamic requests are forwarded to the application server

Rewriteengine on

Rewriterule ^/ekp/(. *\. ( JSP|DO|JWS|APPLETDO) $ balancer://ekpcluster/ekp/$1 [p,l]

Rewriterule ^/ekp/(. *;jsessionid.*) $ balancer://ekpcluster/ekp/$1 [p,l]

Rewriterule ^/ekp/(SD) $ balancer://ekpcluster/ekp/$1 [p,l]

Rewriterule ^/ekp/(trsidsssoproxyservlet) $ balancer://ekpcluster/ekp/$1 [p,l]

#之下ip可指向集群中任意的EKP服务器地址和对应应用端口

Rewriterule ^/ekp/services/(. *) http://192.9.200.103:18080/ekp/services/$1 [p,l]

#section 3 forwarding rule, reverse proxy mode forwarding to application server

#ProxyPassReverse/balancer://ekpcluster

proxypassreverse/http://192.9.200.69:8065/

proxypassreverse/http://192.9.200.115:8060/

#section 4 Apache Equalizer Manager

<Location/ekpcluster-manager>

SetHandler Balancer-manager

#Deny from all

#设定可以访问管理器的主机

Allow from 192.9.200.69

</Location>

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.