Re: [squid-users] url_rewrite question

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Wed, 12 Feb 2014 14:26:30 +1300

On 2014-02-12 13:38, Ricardo Klein wrote:
> Hi,
>
> I have a client who doesnt whant to remember his new internal web
> system URL (ok, ok, but, he pays, he owns), so, he keeps using
> http://online.publicdomain.com instead of
> http://online.internaldomain.local
>
> Following this documentation:
> http://wiki.squid-cache.org/Features/Redirectors#Using_an_HTTP_redirector
>
> I end to a perl script as this:
> #!/usr/bin/perl
> $|=1;
> while (<>) {
> chomp;
> @X = split;
> $url = $X[1];
> $url =~ s/publicdomain\.com/internaldomain\.local/;
> print $X[0]." 302:$url\n";
> }
>
> But, I never have used the redirect_program on squid, and besides I
> dont even know how to set a rule inside squid.conf. And, I havent find
> nothing I could understand in how to set this up and send only the
> right requests to it.
>
> Can anyone help me with that?

When using a helper set url_rewrite_program or redirect_program to the
path of the helper script. And use url_rewrite_access / redirect_access
with ACLs to determine which HTTP requests it affects.

Alternatively if you have Squid-3.3 or later you can use deny_info to do
the redirection without a helper at all. Just place this before any
other allow lines in your http_access rules:

   acl redirectInternal dstdomain .publicdomain.com
   deny_info 302:%P://internaldomain.local%R redirectInternal
   http_access deny localnet redirectInternal

What that does is tell Squid that requests coming from the LAN (localnet
IPs) going to *.publicdomain.com need to be "rejected" using a 302
status response pointing the client (browser) at the same URL with just
internaldomain.local as the domain.

The user(s) can then type in either domain and will always get to the
internal one when on the LAN.

Amos
Received on Wed Feb 12 2014 - 01:26:37 MST

This archive was generated by hypermail 2.2.0 : Wed Feb 12 2014 - 12:00:04 MST