Solved

mod_rewrite load balancing - but mod_rewrite isn't taking.

Posted on 2004-08-12
6
237 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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 …
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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