Hi there,
I'm using Squid 3.1 as part of a proxy chain. I'm trying to make
Squid use the local /etc/hosts file for name resolution before
forwarding the request to the next proxy in the chain, but I've been
unable to make it work, even by explicitly using the hosts_file
directive. I'd be really grateful if anyone could help!
Here's an example:
I'll access a website normally via the proxy, with no weirdness in /etc/hosts
> cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
> echo $http_proxy
http://localhost:3128
> curl http://yahoo.com
The document has moved here.<P>
<!-- w33.fp.sk1.yahoo.com uncompressed/chunked Wed Oct 26 17:12:17
PDT 2011 -->
Now I'll change /etc/hosts to point yahoo.com to google.com. Notice
that the proxy doesn't respect this: it still goes to yahoo.com
rather than google.com.
> cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
74.125.224.148 yahoo.com ### IP of google.com
> echo $http_proxy
http://localhost:3128
> curl http://yahoo.com
The document has moved here.<P>
<!-- w59.fp.sp2.yahoo.com uncompressed/chunked Wed Oct 26 17:13:06
PDT 2011 -->
Now I'll disable the local proxy, and /etc/localhosts is respected.
> unset http_proxy
> curl http://yahoo.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
Here is my squid.conf:
visible_hostname localhost
http_port 3128
acl all src all
acl all_src src all
acl all_dst dst all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl localhost_dst dst 127.0.0.1/32
http_access allow manager localhost
http_access deny manager all_src
http_access allow localhost
http_access deny all_src
http_access allow all_dst
http_access deny localhost_dst
http_reply_access allow all_src
icp_access deny all_src
coredump_dir /tmp
never_direct allow all
no_cache deny all
peer_connect_timeout 120 seconds
strip_query_terms off
access_log /var/log/squid/access.log squid
cache_log /var/log/squid/cache.log
useragent_log /var/log/squid/useragent.log
referer_log /var/log/squid/referer.log
cache_peer XX.XX.XX.XX parent 3128 0 login=XXXXX:XXXXXXXXXXX
hosts_file /etc/hosts
Thanks for any suggestions!
David
Received on Thu Oct 27 2011 - 00:28:29 MDT
This archive was generated by hypermail 2.2.0 : Thu Oct 27 2011 - 12:00:08 MDT