mod_rewrite, mod_proxy, and relative paths
What I have:
------------
A linux box is configured as a forced proxy gateway with iptables
redirecting all port 80 requests to a VirtualHost.
The host rewrites the request to a locally served script and appends the
orginal request as part of the query string.
The script does some processing and then generates a request for the
original URL pieced together from the query string. This itself
generates another port 80 request which is redirected to the
VirtualHost.
This time around the request is proxied using the [P] flag.
The problem:
------------
All this works fine except for relative paths referenced by the
requested page. These end up being
"http://localhost/remote_server_path/..."
Is there a way to preserve the SERVER_NAME info from the original
request, say with SetEnv? Thus far I haven't had much luck with that
method.
I'm far from a UNIX or Apache hacker and could certainly use the help of
greater minds. Thanks in advance. Relavant .conf follows.
Listen *:10000
<Virtual Host *:10000>
RewriteEngine On
RewriteCond %{SERVER_NAME} !10\.0\.255\.1
RewriteRule .* "http://10.0.255.1/cgi-bin/go.pl?%{SERVER_NAME}%
{REQUEST_URI}&" [QSA,L]
RewriteCond %{REQUEST_URI} !go\.pl
RewriteRule ^/cgi-bin/(.*)$ "http://$1" [P]
</VirtualHost>
ProxyRequests On
<Proxy *>
Order deny,allow
Deny from all
Allow from 10.0.255.0/24
</Proxy>
|