Redirect URL In Squid Proxy Server

FREQUENTLY ASKED QUESTIONS (Squid Proxy)
Q: How to redirect a url in squid proxy?



The actual solution for url redirection is "SquidGuard", and i will explain it in coming days.
Here is a small solution for redirecting a url to another url within Squid proxy. 
And its a simple logic, Basically it works as a denying ACL. Squid deny the access to a specified Website and redirect them to a predefined url as an ERROR MESSAGE.  
So this 


Edit the Squid configuration
[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
#Add the 4 lines to the squid.conf configuration file, save and exit.


Reload Squid Server with new configuration
[root@server ~]# service squid reload


As a result when a proxy client access to "bing.com" the Squid server will deny the access and redirect to google.com as an error message.

Was this helpfull ?

4 comments:

gBloger said...

hi, how do I do this for multi website??
in your example it will redirect all bing.com to google.com but

I want redirect
a, b, c to x, y,z
is it possible from squid??

thanks

Andres Mansilla said...

In that case you must use in dstdomain a list with all the domains you want to redirect

like:
acl badsites dstdomain "/etc/squid/list"

create the file list and add all the domains that you wanted to be redirected

ammaraihaan said...

First of all thank you Andres, I followed your original post and it fixed my original query. This was to enforce Google Safesearch. This was done by adding the following lines to the squid.conf file:

#client acl for the lan
acl lan src 10.1.1.0/24

#to deny "google.com"
acl badsites dstdomain .google.com

#Deny with redirect to Google SafeSearch for lan
deny_info http://www.google.co.uk/webhp?safe=vss lan

#Deny badsites to lan
http_reply_access deny badsites lan

I was wandering if the following command would work:
acl badsites dstdom_regex -i *.google.*

I haven't tested the above yet, but plan to test it later this week.

Tasbir Farid said...

Can I use multiple url to be redirected to multiple site:
for example, www.a.com will be redirected to www.x.com
www.b.com to www.y.com
www.c.com to www.z.com etc.

Thanks in advance.

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons