mod_rewrite, mod_proxy, and relative paths

This is a discussion on mod_rewrite, mod_proxy, and relative paths within the Linux Web Servers forums, part of the Web Server and Related Forums category; What I have: ------------ A linux box is configured as a forced proxy gateway with iptables redirecting all port 80 requests ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-29-2006
foo@bar.com
 
Posts: n/a
Default 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>
  #2 (permalink)  
Old 11-29-2006
HansH
 
Posts: n/a
Default Re: mod_rewrite, mod_proxy, and relative paths

<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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:41 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0