httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent Vaills <>
Subject [users@httpd] mod_remoteip and mod_rewrite interactions
Date Sun, 12 Sep 2010 19:45:15 GMT

I use the module mod_remoteip (2.3.5) on Apache httpd 2.2 (Centos 5).
My Apache httpd is behind a load-balancer.

I have a strange behavior with mod_rewrite and mod_remoteip .

Here is a simple configuration for the virtual host that shows the strange
behaviour :
<VirtualHost *:9090>
   DocumentRoot "/var/www/html/"

   RemoteIPHeader X-Forwarded-For

   RewriteLog var/logs/rw.log
   RewriteLogLevel 9

   Options +FollowSymLinks +ExecCGI
   DirectoryIndex index.html
   <Directory "/var/www/html">
      RewriteEngine on
      RewriteRule ^(.*)$ index2.html [QSA,L]

The configuration is quite simple : whatever you requested, Apache always
serves the URI index2.html.

So when I run the following request "wget http://<public IP>:9090/". I
expect to see in the access log file my IP address, but instead this is the
IP address of the load-balancer : -"GET / HTTP/1.1" 304 -

If I take a look at the RewriteLog file I can see the following : [rid#2aaee84d3ab8/initial] (3) [perdir /var/www/html/] strip per-dir
prefix: /var/www/html/ -> [rid#2aaee84d3ab8/initial] (3) [perdir /var/www/html/] applying
pattern '^(.*)$' to uri '' [rid#2aaee84d3ab8/initial] (2) [perdir /var/www/html/] rewrite '' ->
'index2.html' [rid#2aaee84d3ab8/initial] (3) [perdir /var/www/html/] add per-dir
prefix: index2.html -> /var/www/html/index2.html [rid#2aaee84d3ab8/initial] (2) [perdir /var/www/html/] strip
document_root prefix: /var/www/html/index2.html -> /index2.html [rid#2aaee84d3ab8/initial] (1) [perdir /var/www/html/] internal
redirect with /index2.html [INTERNAL REDIRECT]    [rid#2aaee84d85c0/initial/redir#1] (3) [perdir /var/www/html/]
strip per-dir prefix: /var/www/html/index2.html -> index2.html    [rid#2aaee84d85c0/initial/redir#1] (3) [perdir /var/www/html/]
applying pattern '^(.*)$' to uri 'index2.html'    [rid#2aaee84d85c0/initial/redir#1] (2) [perdir /var/www/html/]
rewrite 'index2.html' -> 'index2.html'    [rid#2aaee84d85c0/initial/redir#1] (3) [perdir /var/www/html/]
add per-dir prefix: index2.html -> /var/www/html/index2.html    [rid#2aaee84d85c0/initial/redir#1] (1) [perdir /var/www/html/]
initial URL equal rewritten URL: /var/www/html/index2.html [IGNORING

My IP is known until the "[INTERNAL REDIRECT]" . So, my questions are :
- Is this internal redirect mandatory ?
- Is it normal that my IP address is lost after this redirect ?

I checked and the HTTP header X-Forwarded-For is correctly set.

Laurent Vaills

View raw message