Redirector - Tutorial

Redirector - Tutorial

Mensagempor Lelouch » Ter Jul 07, 2009 11:44 pm

Redirector

Intruduction
This add-on let us remplace some things in many webpages, this is a great idea to show a diferent portals to our users. Too, this include a user control management, you can block users, redirect URLS or use a personalized URL black list for each user.

What are the differences between redirector and "portal cautivo"?
The main diference with "portal cautivo", is that the script of redirector was developed in perl and only work with the oficial squid (coming soon this addon will work for Argento-Squid) So, the differences in programming, extends and exposes a many posibilities that will try explain in this tutorial and an important problem was resolved, the portal now is not saved in cache memory..

Hardware requirements:
Minimum requirements:
Processor: Pentium III .
RAM Memory: 128 MB

Recommended:
Processor: 1 Ghz or better
RAM Memory: 256 or better

Other add-on needed:
Squid.tgz for BrazilFW 2.30.1
Squid.tgz for BrazilFW 2.31.10
Perl.tgz

NOTE: You can found this perl version in the user folder of his author (Angel R.), as indicate the link. Please do not confuse with the other two versions that are used for other addons.

BrazilFW versions:
Redirector work with 2.30.1
Redirector work with 2.31.10
Redirector does not work with 3.0

Subnetting Compatibility
Redirector work with Squid. if you have squid configured to work with subnets, redirector work perfectly. If you don't use subnets, you must configure squid, and no need modify redirector, only add the different ip address to the lists.


Installation:
Before continue to next step please ensure if squid oficial is installed and working perfectly. Install redirector.tgz and perl.tgz perform a typical installation:

Código: Selecionar todos
brazilfw# wget http://www.brazilfw.com.br/users/angelruiz/addons/redirector/redirector.tgz
brazilfw# wget  http://www.brazilfw.com.br/users/angelruiz/addons/perl_oficial/perl.tgz
brazilfw# mt
brazilfw# cp *.tgz /mnt
brazilfw# umt
brazilfw# reboot


Configuration

To run redirector to start at boot time, add the follow text line to rc.local file.

/redirector/./redir.pl

To start redirector (begin to work), add the follow text line to squid_2.tpl: file.

url_rewrite_program /redirector/redirector.pl
redirect_children 15


Note: Is highly important introduce an empty text line to the end of file, if you forget do this; redirector don't will work. Save changes and reboot.

All users with the option "squid.conf create: yes" disabled, must edit the file "squid.conf" to do this go to "files" option from left menu, then click on "edit any file" and paste the follow path:
Código: Selecionar todos
/usr/local/squid/etc/squid.conf


Find the follow text:
Código: Selecionar todos
http_access allow manager localhost
http_access deny PURGE
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports


And complete with the follow text code lines:

Código: Selecionar todos
url_rewrite_program /redirector/redirector.pl
redirect_children 15

acl internal_net src "/usr/local/squid/etc/ipaccess.yes"


Configuration
The follow image shows the posibilities of redirector: IP Block, Redirect an URL, Black URL list, and 3 portals to show different types of information; each portal have a independient IP list to work, This converts in a high flexibility tool at time of customize redirector's functions.

Imagem


Block IP: This function is easy to configure, in "IP list" type the IP addresses that redirector must block. You can use the [Edit index.htm] option to edit the notice that will be displayed for the user when try surf the web.

Then, can see portals that can be used to show notices/advertisements, each portal is different:
Publicity Temp 1: This is used to show the notices/advertisements in top of the browser, the rest of space of browser window is not used for redirector, instead, this is used to show the web page requested for user.

Imagem

Publicity Temp 2: This template shoe the notices/advertisements only four (4) seconds and then this disappear to show the web page requested for user.

Imagem

Publicity Temp 3: This template is similar to the addon called "portal cautivo 2.3", this is used to show the notices/advertisements in the main window navigator, the user must click on "Acept" button to show the web page requested.

Imagem

The portals isn't stored in cache memory. After script is started (reload squid), the Portal is applied to all ips declared, and only will be showing again after of 3600 seconds without any http activity, ie. If the user is surfing the web continuously during 2 hours, the Portal don't will appear again, because the user has not an hour without http traffic. Coming soon the time will be a variable customizable from webadmin.

URL Black List: This function is very similar to the squid black list function, too lets edit the message to show when user request an blocked site.

Remplacement Redirection: This function is very interesting and novel, since it allows us so much to change an url of a page so much in its entirety, like part of her, example: to change the google logo.
First go to Edit remplacement urls and we should indicate 2 URLS, in oneself line; the first indicate the URL that will be replaced, and the second indicates the substitution, both should be separated by a space.

Ie.:
Código: Selecionar todos
http://www.redtube.com 302:http://www.vatican.va/phome_sp.htm

When user request the webpage redtube, the system will be show the page vatican.va

The Redirector too can be used for remplace only one part of the page (images, banners, etc.). A good example: remplace the logo of the most used search engine… Yeah! The Google logo image. To do this:

Código: Selecionar todos
http://www.google.com.br/intl/en_com/images/logo_plain.png 302:http://www.youpage.com/angelr.jpg
http://www.google.com.ar/intl/en_com/images/logo_plain.png 302:http://www.juanillo.com/ramiro.jpg
http://www.google.com.co.ve/intl/en_com/images/logo_plain.png 302:http://www.nacho.com/gamba.jpg


Imagem

Remember: The URLs must be declared using pairs:
Url_A Url_B
Url_C Url_d
Url_B reemplaza a Url_A y Url_d reemplaza a Url_C

The number “302” is used to prevent that the system store the redirection in cache, if you forget it, the redirection (ie. The google logo) must not restored even delete the remplacement, because the client browser store it in cache memory.

Control Actions
|Reload Squid |: Every time that you edit the html of any portal, or add/delete an ip address, must reload squid, if does not the changes not will be applied.
|Reload block |: This function is usted to block users after edit the “ip list”, you must click on “reload squid”, this let block only the port “80”, then, click on “reload block" to run the script to block the rest of ports (the script uses iiptables to block the ports), the follow ports: 8180, 22 don't will blocket to let the use of webadmin and ssh access services.
GNU/Linux addict, instead of Linux addict.
Sou, machigatteita no wa ore ja nai! Sekai no hou da!...
Sekai wa kawaru! Kaerareru...

Hangyaku no Rurūshu...

New scheme: BFW3(LB) - BFW3BridgeCache - ArgentoBridgeQoS
Avatar do usuário
Lelouch
BFW Beneméritos
 
Mensagens: 1324
Registrado em: Dom Out 05, 2008 7:39 pm
Localização: #!/bin/sh
BrazilFW Box: BrazilFW: RAM 3GB, ATHLON X2 5600+, HDD 160GB+120GB, LB: 2Mb+8Mb.
BFW3 BuildTree on GNU/Linux Archlinux 64 bits.

Voltar para BrazilFW 2.x

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado e 1 visitante

cron