Redireccionar web con Tinyproxy [INACTIVE]

Redireccionar web con Tinyproxy

Mensagempor ghost » Dom Mar 29, 2009 4:40 pm

Antes de comenzar con este tutoríal tienen que tener instalado Tinyproxy, si no lo tenes seguí este enlace:
http://www.brazilfw.com.br/forum/viewtopic.php?f=67&t=63979.
Y si no sabes instalar un Add-on segui este otro:
http://www.brazilfw.com.br/forum/viewtopic.php?f=40&t=62637.

Ya teniendo el Tinyproxy instalado podemos comenzar.

Primero vamos a configurar Tinyproxy:
Imagem


Configurar como se ve en la imagen:

Imagem


• 1 Se puede usar otro puerto, si se modifica hay que modificar las reglas que aparecen mas abajo con el puerto usado.
• 2 Yo seleccione Error para que no se sobrecargue el log del sistema. Esta opcion es según las preferencias personales de cada uno.

Hacer click en Edit Configuration File:

Imagem


Usar este archivo de configuración (se puede modificar a gusto):
Código: Selecionar todos
##
## tinyproxy.conf -- tinyproxy daemon configuration file
##

#
# Timeout: The number of seconds of inactivity a connection is allowed to
# have before it closed by tinyproxy.
#
Timeout 600

#
# ErrorFile: Defines the HTML file to send when a given HTTP error
# occurs.  You will probably need to customize the location to your
# particular install.  The usual locations to check are:
#   /usr/local/share/tinyproxy
#   /usr/share/tinyproxy
#   /etc/tinyproxy
#
#ErrorFile 404 "/etc/tinyproxy/404.html"
#ErrorFile 400 "/etc/tinyproxy/400.html"
#ErrorFile 503 "/etc/tinyproxy/503.html"
#ErrorFile 403 "/etc/tinyproxy/403.html"
#ErrorFile 408 "/etc/tinyproxy/408.html"

#
# DefaultErrorFile: The HTML file that gets sent if there is no
# HTML file defined with an ErrorFile keyword for the HTTP error
# that has occured.
#
DefaultErrorFile "/etc/tinyproxy/default.html"

#
# Where to log the information. Either LogFile or Syslog should be set,
# but not both.
#
# Logfile "/var/log/tinyproxy.log"
Syslog On

#
# This is the absolute highest number of threads which will be created. In
# other words, only MaxClients number of clients can be connected at the
# same time.
#
MaxClients 100

#
# These settings set the upper and lower limit for the number of
# spare servers which should be available. If the number of spare servers
# falls below MinSpareServers then new ones will be created. If the number
# of servers exceeds MaxSpareServers then the extras will be killed off.
#
MinSpareServers 5
MaxSpareServers 20

#
# Number of servers to start initially.
#
StartServers 10

#
# MaxRequestsPerChild is the number of connections a thread will handle
# before it is killed. In practise this should be set to 0, which disables
# thread reaping. If you do notice problems with memory leakage, then set
# this to something like 10000
#
MaxRequestsPerChild 0

#
# The following is the authorization controls. If there are any access
# control keywords then the default action is to DENY. Otherwise, the
# default action is ALLOW.
#
# Also the order of the controls are important. The incoming connections
# are tested against the controls based on order.
#
Allow 127.0.0.1

#
# The "Via" header is required by the HTTP RFC, but using the real host name
# is a security concern.  If the following directive is enabled, the string
# supplied will be used as the host name in the Via header; otherwise, the
# server's host name will be used.
#
ViaProxyName "tinyproxy"

#
# The location of the filter file.
#
Filter "/etc/tinyproxy/filter"

#
# If an Anonymous keyword is present, then anonymous proxying is enabled.
# The headers listed are allowed through, while all others are denied. If
# no Anonymous keyword is present, then all header are allowed through.
# You must include quotes around the headers.
#
#Anonymous "Host"
#Anonymous "Authorization"

#
# This is a list of ports allowed by tinyproxy when the CONNECT method
# is used.  To disable the CONNECT method altogether, set the value to 0.
# If no ConnectPort line is found, all ports are allowed (which is not
# very secure.)
#
# The following two ports are used by SSL.
#
#ConnectPort 443
#ConnectPort 563



Presionar OK y volver a la pantalla principal del Tinyproxy para entrar en Edit Filter File:

Imagem


En esta parte se configuran todas las webs que se deseen bloquear, en mi caso tengo las siguientes:

Imagem

Presionar OK y resguardar.

Ahora vamos a configurar el firewall

Imagem

Y des pues a Editar Reglas de Firewall Personalizadas

Imagem


Agregar lo siguiente al archivo:

Código: Selecionar todos
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -A INPUT -p TCP --dport 80 -j ACCEPT
iptables -A OUTPUT -p TCP --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.1:8080
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth0 -p TCP --dport 443 -j ACCEPT


NOTA: Quisas aparezcan algunos errores al iniciar el firewall o al recargarlo, pero todo funciona bien. Se aceptan sugerencias a estas reglas de iptables, con mis conocimientos es lo mejor que pude hacer.


Presionar OK, resguardar y reiniciar. Y con estos pasos ya tendriamos todo configurado y listo. La web se bloquearia con el Tinyproxy y se puede modificar la pagina de error para que contenga alguna información util o se redireccione a otro sitio. Por ejemplo les dejo mi modificacion al archivo default.html del Tinyprox, que no redirecciona a ningun sitio simplemente muestra un buscador personalizado:

Código: Selecionar todos
<html>
<head>
<title>Click24! - {cause}</title>
</head>
<body>
<font face="Tahoma" size="2">Ha ocurrido el siguiente error: {detail} <br>
Inténtelo nuevamente mas tarde o verifique la dirección.</font><hr noshade color="#6B90DA" size="1">
<div align="center">
   <font size="1"><br>
&nbsp;</font><table border="0" width="200" id="table1" cellspacing="0" cellpadding="0">
      <tr>
         <td>
         <p align="center"><b><i><font face="Arial" size="7">Click<font color="#7EB802">24!</font></font></i></b></td>
      </tr>
      <tr>
         <td>
         <p align="right"><b><i><font face="Arial" size="2" color="#616163">
         Internet Simple&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         </font></i></b></td>
      </tr>
   </table>
   <p align="right"><font size="1">&nbsp;</font></div>

<form action="http://www.google.com/cse" id="cse-search-box">
  <div>
    <input type="hidden" name="cx" value="005598971426828566269:ebamnpnkdhk" />
    <input type="hidden" name="ie" value="UTF-8" />
    <div align="center">
      <table border="0" width="450" id="table2" cellspacing="0" cellpadding="0">
         <tr>
            <td><font size="2">Buscar en la web:</font></td>
         </tr>
         <tr>
            <td>
            <p align="center">&nbsp;<input type="text" name="q" size="31" />
    <input type="submit" name="sa" value="Buscar con Google" />
              </td>
         </tr>
      </table>
   </div>
   </div>
</form>
<p align="center"><font size="1">Powered by<br>
</font><b><font color="#0000FF">G</font><font color="#FF0000">o</font><font color="#D7A803">o</font><font color="#0000FF">g</font><font color="#008080">l</font><font color="#FF0000">e</font></b></p>
<hr noshade color="#6B90DA" size="1">
<font size=1 face="Tahoma"><em>Generated by {package} ({version})</em> </font>
</body>
</html>


Ejemplo de una web que redireccione:

Código: Selecionar todos
<html>
<head>
<title>Cargando...</title>
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://www.google.com">
</head>
<body>
<b><font color="#FFFFFF"><span style="background-color: #FF6600">Cargando...
</span></font></b>
</body>
</html>


Espero que les sea de utilidad.

Comentarios y modificaciones al tutotial seran bienvenidos!.
Por favor usar el foro de Ayuda en General para realizar cualquier tipo de consulta y no este post.
Avatar do usuário
ghost
BFW Beneméritos
 
Mensagens: 1351
Registrado em: Qui Abr 24, 2008 8:54 pm
Localização: Tierras Asperas de Zona Sur, Buenos Aires, Argentina
BrazilFW Box: No en uso actualmente

Voltar para Varios tutoriales

Quem está online

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