[Tfug] Squid help?

Jude Nelson judecn at gmail.com
Mon Dec 7 00:32:05 MST 2009


Hello Harry,

export http_proxy="http://localhost:3128" works for wget and urllib2 (the
app I was referring to is written in Python).  Thanks!

Now if I could only find out why Python's httplib doesn't seem to honor the
http_proxy environment variable.

Thank you so much!

Regards,
Jude

On Sun, Dec 6, 2009 at 9:43 PM, Harry McGregor <micros at osef.org> wrote:

> Hi,
>
> Jude Nelson wrote:
> > Harry,
> >
> > I already have a webserver talking to the file system--that's the
> > Python HTTP server.
> >
> > All of my GET requests that I send to Squid fail with:
> >
> > 1259687247.985      0 127.0.0.1 NONE/400 1989 GET
> > /home/jude/Desktop/finals.txt - NONE/- text/html
> >
> Correct, you are asking squid to talk to your file system, not to talk
> to your local webserver, as your wget is talking to port 3128 (squid),
> and not to your local web server.
>
> try:
>
> export http_proxy="http://localhost:3128"
>
> Then wget http://localhost:4000/home/jude/Desktop/finals.txt
>
> You may have to add port 4000 to the Safe_ports in your squid.conf and
> restart/reload squid.
>
> > The problem appears to be that Squid isn't talking to my local HTTP
> > server, despite the fact that the GET request specifies localhost as
> > the hostname.  Any ideas?
> >
> I don't know how to put together a URL for squid to translate...  but by
> exporting a proxy variable, you will redirect all http traffic to the
> proxy, and then you can talk directly to your webserver on port 4000
>
>                      Harry
>
> > Regards,
> > Jude
> >
> >
> >
> > On Sun, Dec 6, 2009 at 8:56 PM, Harry McGregor <micros at osef.org
> > <mailto:micros at osef.org>> wrote:
> >
> >     Hi Jude,
> >
> >     You would need to access your http server, either through squid, or
> >     directly.
> >
> >     Squid can't access the file system directly, and even if it's pulling
> >     from cache will check the "remote" server before serving the file.
> >
> >     What you need is a webserver that will talk to the file system, which
> >     you can then either use squid as an accelerator for your httpd
> >
> >
> >                       Harry
> >
> >     Jude Nelson wrote:
> >     > Hi Harry,
> >     >
> >     > I'm running Debian 5.0.  My Python HTTP server listens on port
> 4000.
> >     > My Squid daemon listens on 3128.  I thought Squid could access
> >     > /var/spool/squid3 for caching files?  All I need to do is get my
> >     > application to put a copy of the file somewhere for Squid to
> >     find.  I
> >     > figured the easiest way to do that would to have an HTTP server
> >     > running on localhost, and have the application use Squid as a
> >     proxy to
> >     > the server so that a GET on the file would go through Squid,
> >     causing a
> >     > cache miss and causing Squid to cache the file automatically.
> >     >
> >     > Thanks,
> >     > Jude
> >     >
> >     > On Sat, Dec 5, 2009 at 11:49 PM, Harry McGregor <micros at osef.org
> >     <mailto:micros at osef.org>
> >     > <mailto:micros at osef.org <mailto:micros at osef.org>>> wrote:
> >     >
> >     >     Jude Nelson wrote:
> >     >     > Hey all,
> >     >     >
> >     >     > I'm trying to use Squid as a file caching mechanism to
> >     fill the
> >     >     > following role:
> >     >     >
> >     >     > (0) the application starts an HTTP server (Python's
> >     default one) on
> >     >     > localhost
> >     >     > (1) the application needs to get a file
> >     >     > (2) the application asks local Squid daemon for the file
> >     >     > (3a) if Squid has it, it gives the application the file
> >     and the
> >     >     > application processes it
> >     >     > (3b) if Squid does not have it, the application will:
> >     >     > (3b(a)) download the file
> >     >     > (3b(a)) put the file into Squid by issuing an HTTP GET
> >     request to
> >     >     > localhost; Squid, being a proxy between the application
> >     and the HTTP
> >     >     > server set up in (0) reads the file into its cache
> >     >     >
> >     >     > Basically, I'm trying to use Squid as a local file cache.  It
> >     >     will not
> >     >     > be accessible from any host except localhost.  However, I
> >     can't ever
> >     >     > establish a connection with Squid--any HTTP GETs I try to
> pass
> >     >     through
> >     >     > Squid, either to a file on localhost or to file on a
> >     remote host,
> >     >     > always result in HTTP 400.  Each line in my
> >     >     > /var/cache/squid3/access.log file looks like this:
> >     >     >
> >     >     > 1259687247.985      0 127.0.0.1 NONE/400 1989 GET
> >     >     > /home/jude/Desktop/finals.txt - NONE/- text/html
> >     >     >
> >     >     > (the aforementioned line was generated via a GET to
> >     >     > "http://localhost:3128/home/jude/Desktop/finals.txt").  My
> >     firewall
> >     >     > settings allow Squid; in fact, turning off the firewall has
> no
> >     >     effect.
> >     >
> >     >     I presume you are talking to squid on it's default port of
> >     3128...
> >     >
> >     >     Squid does not have access to the file system, it only has
> >     access to
> >     >     either http hosts or other protocols you configure it for.
> >     >
> >     >     I don't know the syntax to pass an http request through squid
> >     >     manually,
> >     >     but you should be able to "export
> >     >     http_proxy="http://localhost:3128" and
> >     >     use it to reach a web servr locally.
> >     >
> >     >     what OS platform are you on / distro, etc
> >     >
> >     >     What port is your python webserver listening on?
> >     >
> >     >     >
> >     >     > I am not very familiar with Squid's default settings, and
> >     Google has
> >     >     > yet to reveal anything useful.  Is there something I need to
> >     >     > add/remove to the config?  My ACL already allows requests
> from
> >     >     > localhost, and I haven't changed the default HTTP port.  Is
> >     >     Squid even
> >     >     > capable of fulfilling the roll I want it to fulfill?
> >     >     >
> >     >
> >     >                             Harry
> >     >
> >     >
> >     >     > Thanks,
> >     >     > Jude
> >     >     >
> >     >
> >
> ------------------------------------------------------------------------
> >     >     >
> >     >     > _______________________________________________
> >     >     > Tucson Free Unix Group - tfug at tfug.org
> >     <mailto:tfug at tfug.org> <mailto:tfug at tfug.org <mailto:tfug at tfug.org>>
> >     >     > Subscription Options:
> >     >     > http://www.tfug.org/mailman/listinfo/tfug_tfug.org
> >     >     >
> >     >
> >     >
> >     >     _______________________________________________
> >     >     Tucson Free Unix Group - tfug at tfug.org
> >     <mailto:tfug at tfug.org> <mailto:tfug at tfug.org <mailto:tfug at tfug.org>>
> >     >     Subscription Options:
> >     >     http://www.tfug.org/mailman/listinfo/tfug_tfug.org
> >     >
> >     >
> >     >
> >
> ------------------------------------------------------------------------
> >     >
> >     > _______________________________________________
> >     > Tucson Free Unix Group - tfug at tfug.org <mailto:tfug at tfug.org>
> >     > Subscription Options:
> >     > http://www.tfug.org/mailman/listinfo/tfug_tfug.org
> >     >
> >
> >
> >     _______________________________________________
> >     Tucson Free Unix Group - tfug at tfug.org <mailto:tfug at tfug.org>
> >     Subscription Options:
> >     http://www.tfug.org/mailman/listinfo/tfug_tfug.org
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Tucson Free Unix Group - tfug at tfug.org
> > Subscription Options:
> > http://www.tfug.org/mailman/listinfo/tfug_tfug.org
> >
>
>
> _______________________________________________
> Tucson Free Unix Group - tfug at tfug.org
> Subscription Options:
> http://www.tfug.org/mailman/listinfo/tfug_tfug.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tfug.org/pipermail/tfug_tfug.org/attachments/20091207/dc4c06f1/attachment-0002.html>


More information about the tfug mailing list