[squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
I'll start with the pointedly easy stuff: Squid > 2.6 (tested 3.4, 3.5, 4.0 on Ubuntu Xenial, Debian Jessie, FreeSBD 11.1 using iptables, pf, ipf, ipfilter) does not work at all, when configured as a transparent proxy. Full stop. I went through hundreds of posts on dozens of forums, blogs and other resources, tried dozens and dozens of configurations suggested by those posts, tried all 3 firewall options on BSD, tried two versions of Ubuntu and the various versions of Squid from the apt repos, as well as those in BSD's ports. All of them, 100%, fail in _exactly_ the same way, no matter what my configuration was set to. That result, is that _every single http request I make_ when Squid is configured as a transparent proxy, results in the following response being logged: == 07/Feb/2018:15:10:59 -0500.213 0 192.168.1.1 TAG_NONE/400 3583 GET / - HIER_NONE/- text/html ("-" "-") == When I point a client directly at the proxy, using a browser, curl or anything else, I see: == 07/Feb/2018:15:12:56 -0500.875 82 192.168.1.1 TCP_MISS/302 333 HEAD http://www.java.com/ - HIER_DIRECT/www.java.com - ("-" "curl/7.47.0") == These were the same exact request against the same exact Squid instance. If I use Squid 3.5 on Ubuntu or 3.5 and 4.0 on BSD, the logged entry is _identical_ for every single http request I make, regardless of origin. My Squid configuration is 100% default, identical to the generic config, with the exception of the following lines: == http_port 3128 http_port 3129 intercept tcp_outgoing_address 192.168.1.25 debug_options ALL,9 == I've tried all of the obvious links, blogs and resources I could Google up, and 100% of them fail to function as described. Most people I've seen on the forums who attempt to get this working, throw their hands up in defeat and end up configuring the proxy directly on every client that needs it. My current environment looks like this: [ wireless router: 10.0.1.1 on LAN side, 192.168.1.1 on WAN side ] That router has a firewall script on it that says: == #!/bin/sh PROXY_IP=192.168.2.25 PROXY_PORT=3128 LAN_IP=$(nvram get lan_ipaddr) LAN_NET=$LAN_IP/$(nvram get lan_netmask) iptables -t nat -A PREROUTING -i br0 -s $LAN_NET -d $LAN_NET -p tcp --dport 80 -j ACCEPT iptables -t nat -A PREROUTING -i br0 -s ! $PROXY_IP -p tcp --dport 80 -j DNAT --to $PROXY_IP:$PROXY_PORT iptables -t nat -I POSTROUTING -o br0 -s $LAN_NET -d $PROXY_IP -p tcp -j SNAT --to $LAN_IP iptables -I FORWARD -i br0 -o br0 -s $LAN_NET -d $PROXY_IP -p tcp --dport $PROXY_PORT -j ACCEPT == This takes every packet that hits the router on :80, and sends it to my Squid server on .25, which mangles it and sends it back to 192.168.1.1 (router), and onward back to client who requested it. When I was using 2.6 (without large_file support), I was using this same exact configuration, but http_port was set to 'accel', and I didn't need _any_ NAT/routing rules on the squid side at all. It all "Just Worked(tm)". Now I need to jump through hoops to do pf incantations of rdr/direct-to (but direct-to and direct-reply aren't supported on FreeBSD's pf, only OpenBSD's pf supports that syntax), and iptables PREROUTING and POSTROUTING mojo (also fails). Here's a list of some of the resources I've tried, with 100% failure in every case. There are dozens more that I've lost in my browser history now. * https://wiki.squid-cache.org/ConfigExamples/Intercept/Ipfw * https://wiki.squid-cache.org/SquidFaq/InterceptionProxy#Interception_Caching_packet_redirection_for_OpenBSD_PF * https://www.benzedrine.ch/transquid.html * https://www.unix-experience.fr/2013/create-a-powerfull-proxy-cache-with-squid-and-openbsd-2/ * https://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html * https://adilmehmoodbutt.wordpress.com/2014/02/19/how-to-install-squid3-transparent-proxy-server/ * https://veesp.com/en/blog/how-to-setup-squid-on-ubuntu * https://ubuntuforums.org/showthread.php?t=2210987 * http://ubuntuserverguide.com/2012/06/how-to-setup-squid3-as-transparent-proxy-on-ubuntu-server-12-04.html * http://roberts.bplaced.net/index.php/linux-guides/centos-6-guides/proxy-server/squid-transparent-proxy-http-https I also tried asking in #squid on Freenode (dead channel), and #FreeBSD (helpful folks there, but they too, failed to get this working). So I'm at an impasse. Is this just 100% decoupled from the current codebase, and doesn't work at all? Or is this really meant to be some lengthy archaeology to find the right, working solution for getting this configured in Linux or BSD? It seems like with the hundreds of posts from people out there failing to do this correctly, that there's a great opportunity here to a.) make it work again like it did in v2.6, and b.) document the _precise steps_ required to make it function as a transparent http pr
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 02/07/2018 04:11 PM, setuid wrote: > That router has a firewall script on it that says: > == > #!/bin/sh > PROXY_IP=192.168.2.25 Yes, this is a typo here in email but is correct in the router's firewall script. This should be either 192.168.2.20 or 192.168.1.25; both are Squid caches inside my LAN on Ubuntu and BSD respectively. Here's an example of my ipfw rules, for comparison: == $cmd 00700 deny ip from any to any dst-port 3128 via em0 $cmd 00800 fwd 127.0.0.1,3128 tcp from 192.168.1.0/24 to any dst-port 80 via em0 $cmd 00810 fwd 127.0.0.1,3128 ip from any to any dst-port 21 src-ip 192.168.1.0/24 $cmd 00820 allow ip from any to any dst-port 3128 dst-ip 192.168.1.1 src-ip 192.168.1.0/24 == ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 02/07/2018 04:38 PM, Rafael Akchurin wrote: > If you do not mind looking at other tutorials - these are what we have in the test lab. > https://docs.diladele.com/tutorials/transparent_proxy_ubuntu/index.html > https://docs.diladele.com/tutorials/policy_based_routing_squid/index.html Thanks for the quick reply. Do you have a version of these that is BSD-specific? I'm ultimately going to run Squid exclusively on BSD, although was using Linux as a means to validate that the functionality to do transparent proxying was broken (confirmed in both OS'). I'll give these a go tonight on Ubuntu and see where I get. I do see the Apache/Web Safety hooks as "interesting", but they should be decoupled as they're not required to get this working (and are likely prohibited in many-to-most enterprises who would deploy a proxy in this fashion). ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 02/07/2018 04:38 PM, Rafael Akchurin wrote: > If you do not mind looking at other tutorials - these are what we have in the > test lab. > https://docs.diladele.com/tutorials/transparent_proxy_ubuntu/index.html I can confirm that the instructions in this tutorial results in the same exact failure scenario as all previous attempts and tests (once I removed the unnecessary Apache/Web Safety bits). Firewall rules are: -A INPUT -i eth0 -p tcp -m tcp --dport 3126 -c 0 0 -j ACCEPT -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -c 0 0 -j ACCEPT -A FORWARD -i eth1 -o eth0 -c 0 0 -j ACCEPT Squid config is generic, with the exception of: http_port 3126 intercept There is a single interface on the host, which resides on the LAN _and_ is Internet-facing (eth0). The result is that I get the same as before: ==> /var/log/squid3/access.log <== 1518042565.613 0 192.168.1.1 TAG_NONE/400 3583 GET / - HIER_NONE/- text/html If I point the client (curl, browser, perl + LWP) at the proxy directly on 3128, it works as expected. I am firmly convinved that _transparent_ proxying with squid, is 100% non-functional. The proxy works fine, but transparent proxying is demonstrably broken in anything later than 3.x. ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 2/7/18 4:31 PM, Yuri wrote: > I'm not seen your configuration options for squid. Not squid.conf. Just > ./configure options. Here's what I'm building with (from 'make config' in ports tree) '--bindir=/usr/local/sbin' '--build=amd64-portbld-freebsd11.1' '--datadir=/usr/local/etc/squid' '--disable-arch-native' '--disable-ecap' '--disable-epoll' '--disable-esi' '--disable-ipf-transparent' '--disable-ipv6' '--disable-linux-netfilter' '--disable-linux-tproxy' '--disable-pf-transparent' '--disable-silent-rules' '--disable-snmp' '--disable-ssl' '--disable-ssl-crtd' '--disable-stacktraces' '--disable-translation' '--enable-auth' '--enable-auth-basic=DB '--enable-auth-digest=file' '--enable-auth-negotiate=none' '--enable-auth-ntlm=fake '--enable-build-info' '--enable-cache-digests' '--enable-delay-pools' '--enable-disk-io=DiskThreads '--enable-eui' '--enable-external-acl-helpers=file_userip '--enable-follow-x-forwarded-for' '--enable-forw-via-db' '--enable-htcp' '--enable-http-violations' '--enable-icap-client' '--enable-icmp' '--enable-ident-lookups' '--enable-ipfw-transparent' '--enable-kqueue' '--enable-loadable-modules' '--enable-log-daemon-helpers=file' '--enable-removal-policies=lru '--enable-security-cert-validators=fake' '--enable-storeid-rewrite-helpers=file' '--enable-storeio=aufs '--enable-url-rewrite-helpers=fake' '--enable-wccp' '--enable-wccpv2' '--enable-zph-qos' '--infodir=/usr/local/info/' '--libexecdir=/usr/local/libexec/squid' '--localstatedir=/var' '--mandir=/usr/local/man' '--prefix=/usr/local' '--sbindir=/usr/local/sbin' '--sysconfdir=/usr/local/etc/squid' '--with-default-user=squid' '--with-large-files' '--with-logdir=/var/log/squid' '--with-pidfile=/var/run/squid/squid.pid' '--with-swapdir=/var/squid/cache' '--without-gnutls' '--without-gss' '--without-heimdal-krb5' '--without-mit-krb5' '--without-nat-devpf' '--without-nettle' ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 2/7/18 5:37 PM, Rafael Akchurin wrote: > How is your network configured? Your rules indicate you have 2 nics but you > later say you have one.. Originally, I started with 1 NIC (it's a VM), and added 2 more, because I read that pf/ipfw can't rewrite ingress packets on the same interface it used for egress, but I haven't tried creating a bridge and routes to attempt to make that work yet. The Ubuntu machine has 2 NICs; primary NIC is WAN facing (internet routable IP bound to eth0) and the secondary NIC sits on the "backup" network (LAN-side) on 192.168.2.x. Let's break it down: [WAN router] |-- LAN: 192.168.1.1 (wired LAN) `-- WWAN: 10.0.1.1 (wireless clients) BSD VM: 192.168.1.25 Ubuntu VM: |-- INET: 32.215.x.x `-- LAN: 192.168.2.x The WAN router is what sends traffic sent over it on :80, over to .1.25 (BSD) to cache. Previously, I had it pointed to Squid 2.6 sitting on my NAS (192.168.1.20) and that would work perfectly as a transparent proxy. When I pointed the WAN router to .25 instead of .20, and upgraded the version of Squid by using BSD's version from ports on .25, this process all fell apart. So... is having 3 NICs (1 NIC + 2 bridged together as bridge0) *now* a requirement to get transparent proxying working with anything using Squid 3.x or later? Can this be done with a single NIC sitting on an Internet-facing LAN segment? If so, how? ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 2/7/18 6:36 PM, Yuri wrote: > Did you used ipfw NAT configuration on same box with squid? Yes, my ipfw configuration is: $cmd 00700 deny ip from any to any dst-port 3128 via em0 $cmd 00800 fwd 3128 tcp from 192.168.1.25 to any dst-port 80 via em0 $cmd 00820 allow ip from any to any dst-port 3128 dst-ip 192.168.1.25 src-ip 192.168.1.1 $cmd add 6 permit ip from any to any ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users
Re: [squid-users] Squid 3.x or 4.x acting as a transparent http proxy (NOT https)
On 02/22/2018 12:29 PM, Eliezer Croitoru wrote: > Is this issue still unresolved? > After reading the whole thread and getting back to the first post I really don't understand the issue. No, unresolved. At this point, I'm firmly convinced that Squid 3.x and later _does not_ work as a fully transparent proxy on either FreeBSD nor Linux, full stop. Any version of Squid earlier than 3.x, works flawlessly in this regard with a similar configuration. ___ squid-users mailing list squid-users@lists.squid-cache.org http://lists.squid-cache.org/listinfo/squid-users