Re: [squid-users] Reverse proxy with Url path problem

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Fri, 15 Jul 2011 14:38:41 +1200

On 15/07/11 01:41, Pschittt wrote:
> Well,
>
> That will work if I have only one server behind squid.
>
> The fact is I have 2 servers behind squid :
> http://mywebserver/serv1 -> http://192.168.2.1:2048
> http://mywebserver/serv2 -> http://192.168.2.2:4096
>
> And those servers must be accessible only via Squid (the reverse proxy
> purpose...).
>
> I tried to use rewrite_program, doing a perl script which rewrite the
> URL. But like I said, the server 192.168.2.1 cannot be accessible
> directly...

When re-writing it is not. Leave the public domain (which DNS points at
Squid) on the URL. Your re-writer should only strip away the "/serv1" or
"/serv2" part of the URL. This is done with a regex strip, for any
number of servers.

Something like:

#!/bin/perl
$1|=;
while(<>) {
   print s/\/serv[12]//;
}

The problem is that the servers might generate URLs without the right
/serv1, /serv2 bit on them and clients get errors when they try to load
that URL.

Amos

-- 
Please be using
   Current Stable Squid 2.7.STABLE9 or 3.1.14
   Beta testers wanted for 3.2.0.9
Received on Fri Jul 15 2011 - 02:38:47 MDT

This archive was generated by hypermail 2.2.0 : Fri Jul 15 2011 - 12:00:02 MDT