Apache rewrite the specified URL to a specified number of servers

Source: Internet
Author: User
Tags tomcat

The existing is Apache load balanced to 6 different tomcat above, today encountered the need to forward some specified URL to the specified 3 Tomcat requirements, must be modified rewrite rule rules, online search for a half-day, there is no good solution, Then I stumbled across Rewritemap and found that I could customize the function and used it as follows:

Rewritemap Servers Rnd:/wd/apache2/conf/serversmap.txt

Rewriterule ^/(. +) (Relax/phonelottery) (. +) http://192.168.28.27:${servers:port}/$1$2$3 [P]

Where ${servers:port} represents the value from the Rewritemap servers to obtain the key port (Rnd is random, which means random fetching), and this value exists in the/wd/apache2/conf/serversmap.txt file

Open File/wd/apache2/conf/serversmap.txt

More/wd/apache2/conf/serversmap.txt

Port 8086|8085|8084

So it can be solved.

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.