Solved

mod_rewrite load balancing - but mod_rewrite isn't taking.

Posted on 2004-08-12
6
236 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
  • 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
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.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 250 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

861 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