Re: [squid-users] Squid interworking with a ftp proxy

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Tue, 24 Aug 2004 23:45:37 +0200 (CEST)

On Wed, 25 Aug 2004, Wan Kwong Yeung wrote:

> Understood that Squid is not a ftp proxy, however, it may be required to
> interwork with an upstream ftp proxy.

Ok.

user@host type FTP proxies is accessible via Squid, either by manually
translating the FTP proxy request into URL syntax or using a redirector
to do so for you.

FTP URL syntax is

   ftp://user:password@host/path/to/file

In a user@host FTP proxy environment host is the name of the proxy server,
user is user@ftp.server.name (i.e. anonymous@..) and password is what is
to be used as password (usually your email for anonymous FTP). Each @ sign
or other strange characters in the differen fields of the ftp:// URL needs
to be URL encoded in %nn syntax.

Example:

   FTP Proxy: ftpproxy.example.com

   FTP Server: ftp.example.org

   Login: Anonymous

   Password: hno@

   File: /pub/example.txt

Is equivalent to the URL

ftp://Anonymous%40ftp.example.org:hno%40@ftpproxy.example.com/pub/example.txt

Doing this in a redirector is relatively easy.

#!/usr/bin/perl -p

if ( m%^ftp://(([^@:/]*)(:([^@/]*))@)?([^/]+)(\S*)% ) {
    my ($login, $password, $host, $file) = ($2, $4, $5, $6);
    my $proxy = "ftpproxy.example.com";
    $login = "Anonymous" if ($login eq "");
    $password = "Squid%40" if ($password eq "" && (lc($login) eq "anonymous" || lc($login) eq "ftp"));
    $_ = "ftp://${login}%40${host}:${password}\@${proxy}${file}\n";
    next;
}

Regards
Henrik
Received on Tue Aug 24 2004 - 15:45:41 MDT

This archive was generated by hypermail pre-2.1.9 : Wed Sep 01 2004 - 12:00:02 MDT