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.



Author
LABELS:
5 comments:
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
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
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.
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.
acl a_site dstdomain .a.com
acl b_site dstdomain .b.com
acl c_site dstdomain .c.com
deny_info http://www.x.com lan
http_reply_access deny a_site lan
deny_info http://www.y.com lan
http_reply_access deny b_site lan
deny_info http://www.z.com lan
http_reply_access deny c_site lan
This is just a guess, you may have to create duplicates of lan with different names (eg lan1, lan2, lan3) to prevent message conflicts. In a case like this though I would redirect all to a website with the request URL in a query string, then parse that on a server and redirect from there.
Post a Comment