LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can't get dansguardian with squid to work - The requested URL could not be retrieved (https://www.linuxquestions.org/questions/linux-software-2/cant-get-dansguardian-with-squid-to-work-the-requested-url-could-not-be-retrieved-4175519587/)

Budzin 09-21-2014 04:22 AM

Can't get dansguardian with squid to work - The requested URL could not be retrieved
 
Hello.
I am trying to configure squid proxy to run along dansguardian filter. The squid proxy and the DansGuardian filter are located on a netbook, which is connected to my pc through 2 routers and a bridge. Here are my iptables:

Code:


*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
# ssh
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
# dansguardian
-A INPUT -i p33p1 -p tcp --dport 8080 -j ACCEPT
# squid
-A INPUT -i p33p1 -p tcp --dport 3128 -j ACCEPT
# ts3
-A INPUT -p tcp --dport 30033 -j ACCEPT
-A INPUT -p tcp --dport 10011 -j ACCEPT
-A INPUT -p udp --dport 9987 -j ACCEPT
# related streams
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#-A INPUT -j LOG --log-prefix "DROPPED_INPUT: "
COMMIT
*nat
:PREROUTING ACCEPT [29920:4472079]
:POSTROUTING ACCEPT [1268:86089]
:OUTPUT ACCEPT [1310:88657]
# opendns
-A PREROUTING -i p33p1 -p udp --dport 53 -j DNAT --to-destination 208.67.222.123:53
# dansguardian routing
-A OUTPUT -p tcp --dport 80 -m owner --uid-owner squid -j ACCEPT
-A OUTPUT -p tcp --dport 3128 -m owner --uid-owner squid -j ACCEPT
-A OUTPUT -p tcp --dport 80 -m owner --uid-owner dansguardian -j ACCEPT
-A OUTPUT -p tcp --dport 3128 -m owner --uid-owner dansguardian -j ACCEPT
-A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080
-A OUTPUT -p tcp --dport 3128 -j REDIRECT --to-ports 8080
-A PREROUTING -i p33p1 -p tcp --dport 80 -j REDIRECT --to-port 8080
# squid routing
-A PREROUTING -i p33p1 -p tcp --dport 80 -j REDIRECT --to-port 3128
# NAT
-A POSTROUTING -s 192.168.0.0/16 -j MASQUERADE
-A POSTROUTING -s 10.0.0.0/16 -j MASQUERADE
-A POSTROUTING -s 172.16.34.252/30 -j MASQUERADE
COMMIT

And here's my squid.conf:
Code:

#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src 127.0.0.0/8
acl localnet src fc00::/7      # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
acl localhost src 127.0.0.1/32

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210        # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl CONNECT method CONNECT

#acl bdomains dstdomain "/etc/squid/blocked.domains.acl"
#http_access deny bdomains

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
#http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
#http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
#http_access allow localhost manager
#http_access deny manager


#debug_options 28,9

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access allow all

# Squid normally listens to port 3128
http_port 3128 transparent
#http_port 3128 intercept
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:          1440    20%    10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0    0%      0
refresh_pattern .              0      20%    4320

When the entry corresponding to the dansguardian routing in iptables is hashed out - the internet works fine.

Code:

# -A PREROUTING -i p33p1 -p tcp --dport 80 -j REDIRECT --to-port 8080
When it isn't - Dansguardian seems to block blacklisted sites, but when I try to access normal sites I get the "The requested URL could not be retrieved" and "Access denied" error from squid (not Dansguardian). I tried configuring squid.conf and iptables by trial and error method without any luck. Squid without dansguardian works fine - it allows me to access sites, but when dansguardian is turned on I cannot access the internet because of the access denied error that squid is giving me. What changes should I make to above files? Please help.

Budzin 09-21-2014 10:11 AM

I checked the Squid's cache log by using tail-f cache.log and I think the cause of this problem is a forwarding loop:

Code:

2014/09/21 17:04:57 kid1| WARNING: Forwarding loop detected for:
GET / HTTP/1.1
User-Agent: -----------------------------
Host: solomid.net
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: pl,en;q=0.9,cs;q=0.8,pl-PL;q=0.7
Accept-Encoding: identity,gzip,deflate
Cookie: __utma=54353066.32666949.1411309119.1411309119.1411309119.1; __utmc=54353066; __utmz=54353066.1411309119.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Via: 1.0 -----------.pl (squid/3.3.13)
X-Forwarded-For: 172.16.34.254, 127.0.0.1
Cache-Control: no-cache
Connection: keep-alive

Also when restarting Squid, with Dansguardian enabled in iptables i get this error:

Code:

2014/09/21 17:12:52 kid1| ERROR: listen( FD 12, [::] [ job2], 4096): (98) Address already in use
How can I get rid of this forwarding loop?


All times are GMT -5. The time now is 10:44 PM.