PDA

View Full Version : SQUID Proxy redirection URLs



creation4251
November 29th, 2020, 04:51 PM
Morning guys,
I'm trying to redirect specific URLs to another one just using the instance "deny_info". So when from my browser I want to go to www.A.com (http://www.a.com/) squid proxy will redirect to www.B.com (http://www.b.com/) authomatically.
From docuemntation I can see that this is possible in Ubuntu but I am not totally sure how to use this instance inside squid.conf.
Any suggestion or examples?
Thanks!

EuclideanCoffee
November 29th, 2020, 05:09 PM
The wiki explains how to accomplish this with scripts. It's a bit involved.

https://wiki.squid-cache.org/Features/Redirectors

Here's an example.

https://gist.github.com/peter279k/ea81a487ae0db811894687b8178b3175

Here's a question asking how to accomplish this explicitly, but the answer says it won't be possible for HTTPS unless squid is configured as a MitM.

https://serverfault.com/questions/764855/redirect-certain-https-url-with-squid

The final result is this HTTP template from this source. I'll copy it here for convenience.

https://servercomputing.blogspot.com/2012/03/squid-proxy-redirect-url.html



[root@server ~]# vi /etc/squid/squid.conf
acl lan src 192.168.10.0/24 #client acl for the lan
acl badsites dstdomain .bing.com #to deny "bing.com"
deny_info http://google.com lan #Deny with redirect to google.com for lan
http_reply_access deny badsites lan # Deny badsites to lan
[root@server ~]# service squid reload


I think it's easier to enforce these controls with your own proxy server. Having a local proxy server is not secure.

Edit.

Couldn't you accomplish this easier with host files?

creation4251
December 2nd, 2020, 04:29 PM
Hi thanks for your answer.

I would like to know if allocating those ACL under the following one is ok?

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1


# 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 fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines


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 lan src 192.168.10.0/24 #client acl for the lan
acl badsites dstdomain .bing.com #to deny "bing.com"
deny_info http://google.com lan #Deny with redirect to google.com for lan
http_reply_access deny badsites lan # Deny badsites to la


After that, if i reload the squid i get this error:

sudo /etc/init.d/squid reload
squid: ERROR: Could not send signal 1 to process 6864: (3) No such process



sudo /etc/init.d/squid status
squid dead but pid file exists

I tried to reload few times the squid proxy, i restarted the machine and also deleted the var/run pid file and cache from squid.
Same issue all the time.