Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have Squid setup to allow access to only specific web sites. What I would like to be able to do is if they type in something like linuxquestions.org have it automatically return them to our department's web page.
So regardless of what url is typed in the browser, I want them to see the department page unless it's a site on the allowed list.
squid can't do this internally... you need to use a redirector script...
the script would be called from within the squid.conf file with the tag:
Code:
redirect_program
here's the relevant info from the squid.conf.default file:
Quote:
# TAG: redirect_program
# Specify the location of the executable for the URL redirector.
# Since they can perform almost any function there isn't one included.
# See the FAQ (section 15) for information on how to write one.
# By default, a redirector is not used.
#
#Default:
# none
# TAG: redirect_children
# The number of redirector processes to spawn. If you start
# too few Squid will have to wait for them to process a backlog of
# URLs, slowing it down. If you start too many they will use RAM
# and other system resources.
#
#Default:
# redirect_children 5
# TAG: redirect_rewrites_host_header
# By default Squid rewrites any Host: header in redirected
# requests. If you are running an accelerator this may
# not be a wanted effect of a redirector.
#
#Default:
# redirect_rewrites_host_header on
# TAG: redirector_access
# If defined, this access list specifies which requests are
# sent to the redirector processes. By default all requests
# are sent.
#
#Default:
# none
there's an example perl script there... i've never written a redirect script, but it doesn't seem to be very complicated... and for a solution as simple as the one you are trying to implement it would probably be trivial...
i have created a simple perl script to reach atl02wrx's goal using the example in section 15 of the squid FAQ...
Code:
DISCLAIMER: i am in NO WAY a coder so don't take this as
anything more than a PROOF OF CONCEPT script...
having said that, i actually tested the script somewhat on my squid 2.5 (stable10) box and it seems to work fine - AFAIK it does what it's supposed to do...
the example i've posted will allow users to connect ONLY to these HTTP sites:
- directory.google.com
- www.google.com
- news.google.com
- maps.google.com
if any other URL is entered, the user will be redirected to http://directory.google.com
to install it i just saved the script as /var/squid/example.pl, made it executable, made it owned by the squid user, and added this line to my squid.conf:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.