Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mod_rewrite load balancing - but mod_rewrite isn't taking.

Posted on 2004-08-12
6
Medium Priority
?
239 Views
Last Modified: 2010-03-04
I am trying to use mod_rewrite to load balance an indefinite number of web servers, using the explanation provided by the Apache Group at http://www.engelschall.com/pw/apache/rewriteguide/#ToC29

I copied the description they gave in the article verbatim, only changing the specifics concerning my servers in the perl script (they are on IPs instead of DNS names, and there are less of them). Then I took their httpd.conf description and applied them (again, verbatim) to the httpd.conf file, only changing the location of the perl script. Now, from what I understand of mod_rewrite (which isn't much, I'll admit), the RewriteRule should be taking, and sending me to alternate servers. However, all that the "connection" server does is show the default index page I have on it.

Specifics:
1) RedHat Linux, v9.0 running Apache 2.0.40
2) Location of perl program /var/www/iscripts/loadbalance.pl
3) I have 2 boxes set up. One runs 2 virtual servers, each running off their own IP (through eth aliasing). Both of those virtual servers are running fine and dandy. I can connect perfectly to them. The other is running only the version of Apache with mod_rewrite.
4) The way I am running the servers, one is connected to the other with a crossover cable. While this may be the problem, I highly doubt it. Both can see each other no-problem. (SSH, connecting to the actual Apache servers, etc... all of it works)

I have analyzed everything that I could. There are no typos in any of the configuration files, the perl script works as it should (no bugs).... I am lost. The only thing that I can think of that I havn't tried is using the RewriteLock directive, but I don't know how it's supposed to be used, and I can't find an example of it.

Any help that you guys can give would be highly appreciated. Thanks!
0
Comment
Question by:bisonfur37
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11791663
are you shure that thedb.pl script is called by apache, and that it returns status 0?
If in doubt, add some debugging output to a file in the script.
0
 
LVL 2

Author Comment

by:bisonfur37
ID: 11793289
From what I can tell, the program is not supopsed to exit, it is supposed to continuously run in the background... but I'll take your advice about the debugging output, to ensure that it runs.

OK, this is odd. I perfomred the debugging output like you asked, and the stranges thing happened... all of a sudden, it started working. After that, I removed the debugging output, and it continued.

My question now becomes: what could have caused such erratic behavior?
0
 
LVL 2

Author Comment

by:bisonfur37
ID: 11793885
Alright, so I figured out what was causing the problems yesterday. The RewriteRule on the Apache URL Rewriting Guide (link in the origional question) uses the proxy "[P]" flag at the end of the rule. when I remove that flag, the "connection" server redirects to the other servers.

Unfortunately, this is not the behavior I want to use; I want to use the "connection" server as a proxy to the other servers. This will allow me to keep the "serving" webservers in a "trusted zone", and use the "connection" server as a bastion host/etc.

So, is there some additional directive, or a change in the rule, that I have to add to my httpd.conf file to make it actually work with the [P] flag?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 11794694
try [P,L]
0
 
LVL 2

Author Comment

by:bisonfur37
ID: 11831647
I figured out the problem... it turns out that in the URL Rewriting Guide, there is an error in the regular expression that I passed over.

The RewriteRule directive's regular expression should read:
  $/(.*)^
Or:
  $(.+)^
Not:
  $/(.+)^
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11831675
hmm, you mean
  ^(.+)$
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question