Solved

mod_rewrite load balancing - but mod_rewrite isn't taking.

Posted on 2004-08-12
6
232 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Help with htaccess under apache 7 23
Redirect from old domain to new domain 19 68
local dns 2 117
PHP Register global 21 64
As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now