Apache Server configuration support - mod_rewrite, mod_proxy, and relative paths

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > November 2006 > mod_rewrite, mod_proxy, and relative paths





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author mod_rewrite, mod_proxy, and relative paths
foo@bar.com

2006-11-29, 7:24 pm

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>
HansH

2006-11-29, 7:24 pm

<foo@bar.com> schreef in bericht
news:Xns988AA9382366E212015975@130.81.64.196...
> 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.
>
> 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>
>

This might do your tric ...
.... replace %{SERVER_NAME} with %{HTTP_HOST}

HansH


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com