Home | Forum | MAN Pages | Tutorials | Directory | HOWTOs | About Me | Contact
 
Squid HOWTOs
1. About Squid
2. Getting and Compiling Squid
3. Installing and Running Squid
4. Configuration issues
5. Communication between browsers and Squid
6. Squid Log Files
7. Operational issues
8. Memory
9. The Cache Manager
10. Access Controls
11. Troubleshooting
12. How does Squid work?
13. Multicast
14. System-Dependent Weirdnesses
15. Redirectors
16. Cache Digests
17. Interception Caching/Proxying
18. SNMP
19. Squid version 2
20. httpd-accelerator mode
21. Related Software
22. DISKD
23. Authentication
24. Terms and Definitions
25. Security Concerns
FAQS
» Advanced Routing & Traffic Control
» General FAQ
» Squid Proxy Server
» Sendmail
» Fetchmail
» Postfix
» Connecting Mobile Phone
» Paging from Linux
» Standard Commands
» Some common terms
Linux HOWTOs
- Single List of HOWTOs
-
Warning: file(link1.inc) [function.file]: failed to open stream: No such file or directory in /home/.showoff/linuxfaqs/linux-faqs.com/link1.php on line 12

Warning: Invalid argument supplied for foreach() in /home/.showoff/linuxfaqs/linux-faqs.com/link1.php on line 16

-
Warning: file(link2.inc) [function.file]: failed to open stream: No such file or directory in /home/.showoff/linuxfaqs/linux-faqs.com/link2.php on line 12

Warning: Invalid argument supplied for foreach() in /home/.showoff/linuxfaqs/linux-faqs.com/link2.php on line 16

-
Warning: file(link3.inc) [function.file]: failed to open stream: No such file or directory in /home/.showoff/linuxfaqs/linux-faqs.com/link3.php on line 12

Warning: Invalid argument supplied for foreach() in /home/.showoff/linuxfaqs/linux-faqs.com/link3.php on line 16

-
Warning: file(link4.inc) [function.file]: failed to open stream: No such file or directory in /home/.showoff/linuxfaqs/linux-faqs.com/link4.php on line 12

Warning: Invalid argument supplied for foreach() in /home/.showoff/linuxfaqs/linux-faqs.com/link4.php on line 16

-
Warning: file(link5.inc) [function.file]: failed to open stream: No such file or directory in /home/.showoff/linuxfaqs/linux-faqs.com/link5.php on line 12

Warning: Invalid argument supplied for foreach() in /home/.showoff/linuxfaqs/linux-faqs.com/link5.php on line 16

-
Warning: file(link6.inc) [function.file]: failed to open stream: No such file or directory in /home/.showoff/linuxfaqs/linux-faqs.com/link6.php on line 12

Warning: Invalid argument supplied for foreach() in /home/.showoff/linuxfaqs/linux-faqs.com/link6.php on line 16

- IRC
- Linux-Crash-HOWTO
- Linux+Windows-HOWTO
- NET3-4-HOWTO
- PA-RISC-Linux-Boot-HOWTO
- Plug-and-Play-HOWTO
- Security-Quickstart-Redhat-HOWTO
- Serial-HOWTO
- Swap-Space
- Unicode-HOWTO
- Virtual-Web
- WWW-HOWTO
- XDM-Xterm
- ADSL Bandwidth Management
- Compile Apache
- Make a Bootdisk
- Linux-Windows9x-Grub
- Linux-Windows
- Linux Crash Recovery
- Optimise Squid
- Block websites in Squid
- Broadcast webcam in linux
- Compile RedHat Linux kernel
- Implement Firewall Security
- Increase Harddrive Performance
- Mount NTFS filesystem
- Patch / rebuild SRPM
- Secure Linux
- Set up a DHCP Server
- Set up an FTP server
- Set up Linux as a Router
- Use Cron
- Samba
Miscellaneous
» All Ports
» Spammers fetch email addresses
» Mounting NTFS in linux
» Linux Gazette
» Linux Man Pages
» Linux Directory
Linux Man Pages
- Section 1
- Section 2
- Section 3
- Section 4
- Section 5
- Section 6
- Section 7
- Section 8
Linux Directory
- General Information
- Linux Hardware
- Software / Applications
- Web Technology
- Software Development
- Linux Distributions
- Linux Publications
- Linux Beginners


 
Next Previous Contents

15. Redirectors

15.1 What is a redirector?

Squid has the ability to rewrite requested URLs. Implemented as an external process (similar to a dnsserver), Squid can be configured to pass every incoming URL through a redirector process that returns either a new URL, or a blank line to indicate no change.

The redirector program is NOT a standard part of the Squid package. However, some examples are provided below, and in the "contrib/" directory of the source distribution. Since everyone has different needs, it is up to the individual administrators to write their own implementation.

15.2 Why use a redirector?

A redirector allows the administrator to control the locations to which his users goto. Using this in conjunction with interception proxies allows simple but effective porn control.

15.3 How does it work?

The redirector program must read URLs (one per line) on standard input, and write rewritten URLs or blank lines on standard output. Note that the redirector program can not use buffered I/O. Squid writes additional information after the URL which a redirector can use to make a decision. The input line consists of four fields:

        URL ip-address/fqdn ident method

15.4 Do you have any examples?

A simple very fast redirector called SQUIRM is a good place to start, it uses the regex lib to allow pattern matching.

Also see jesred.

The following Perl script may also be used as a template for writing your own redirector:

        #!/usr/local/bin/perl
        $|=1;
        while (<>) {
                s@http://fromhost.com@http://tohost.org@;
                print;
        }

15.5 Can I use the redirector to return HTTP redirect messages?

Normally, the redirector feature is used to rewrite requested URLs. Squid then transparently requests the new URL. However, in some situations, it may be desirable to return an HTTP "301" or "302" redirect message to the client. This is now possible with Squid version 1.1.19.

Simply modify your redirector program to prepend either "301:" or "302:" before the new URL. For example, the following script might be used to direct external clients to a secure Web server for internal documents:

#!/usr/local/bin/perl
$|=1;
        while (<>) {
                @X = split;
                $url = $X[0];
                if ($url =~ /^http:\/\/internal\.foo\.com/) {
                        $url =~ s/^http/https/;
                        $url =~ s/internal/secure/;
                        print "302:$url\n";
                } else {
                        print "$url\n";
                }
        }

Please see sections 10.3.2 and 10.3.3 of RFC 2068 for an explanation of the 301 and 302 HTTP reply codes.

15.6 FATAL: All redirectors have exited!

A redirector process must exit (stop running) only when its stdin is closed. If you see the ``All redirectories have exited'' message, it probably means your redirector program has a bug. Maybe it runs out of memory or has memory access errors. You may want to test your redirector program outside of squid with a big input list, taken from your access.log perhaps. Also, check for coredump files from the redirector program.

15.7 Redirector interface is broken re IDENT values

I added a redirctor consisting of

#! /bin/sh
/usr/bin/tee /tmp/squid.log
and many of the redirector requests don't have a username in the ident field.

Squid does not delay a request to wait for an ident lookup, unless you use the ident ACLs. Thus, it is very likely that the ident was not available at the time of calling the redirector, but became available by the time the request is complete and logged to access.log.

If you want to block requests waiting for ident lookup, try something like this:

acl foo ident REQUIRED
http_access allow foo


Next Previous Contents
 
Random Linux Commands
GNOME
The "GNU Network Object Model Environment", GNOME is part of the GNU project and part of the free software, or open source movement. GNOME is a Windows-like desktop system that works on UNIX and UNIX-like systems and is not dependent on any one window manager. The current version runs on Linux, FreeBSD, IRIX and Solaris. The main objective of GNOME is to provide a user-friendly suite of applications and an easy-to-use desktop. Gnome is used by Redhat as the default GUI.

Common Linux terms
Linux-FAQs Forum Categories
» About Forum
» Hardware Troubleshooting in Linux
» Linux Entertainment
» Resources
» Software toubleshooting and configuration
All Linux-FAQs Forums
» Crash Recovery
» FAQs
» Forum Talk
» Games
» General
» Linux Audio Support
» Linux Hardware / Driver
» Linux Installation Support
» Linux misc.
» Linux Networking
» Linux Newbies
» Linux Printing Support
» Linux Security
» Linux Video Support
» Mail Server
» Multimedia
» Tutorials
» Web Proxy Server
» Web Server


 
Powered by HTML
Linux-faqs.com Copyright, All rights reserved www.linux-faqs.com. Peeyush Maurya.