Problemas con SQUID
Publicado por Pedro (6 intervenciones) el 10/06/2008 18:30:16
Tengo una aplicación en linux que descarga recursos por http. He instalado y configurado squid para que actúe como un proxy transparente con la idea de que cuando vaya a descargarse recursos se cacheen y no esté siempre descargándolo del servidor http (es otra máquina) pero no me funciona.
El contenido del fichero squid.conf es el siguiente:
ache_effective_user squid
cache_effective_group squid
cache_mem 300 MB
cache_dir ufs /var/spool/squid 700 32 512
http_port 3128 transparent
icp_port 3130
cache_peer localhost.home.nl parent 8080 0 default
acl HOME dstdomain .home.nl
always_direct allow all
never_direct allow all
Parte de las trazas del fichero cache.log son las siguientes:
2008/06/10 18:26:18| Accepting proxy HTTP connections at 0.0.0.0, port 3128, FD 13.
2008/06/10 18:26:18| commBind: Cannot bind socket FD 14 to *:3128: (98) Address already in use
No entiendo porque dice address already in use porque no se está usando.
En internet he encontrado que había que ejecutar lo siguiente (lo he ejecutado y nada):
#!/bin/sh
# ------------------------------------------------------------------------------------
# See URL: http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html
# (c) 2006, nixCraft under GNU/GPL v2.0+
# -------------------------------------------------------------------------------------
# squid server IP
SQUID_SERVER="192.168.240.23"
# Interface connected to Internet
INTERNET="eth0"
# Interface connected to LAN
LAN_IN="eth0"
# Squid port
SQUID_PORT="3128"
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
#modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
El contenido del fichero squid.conf es el siguiente:
ache_effective_user squid
cache_effective_group squid
cache_mem 300 MB
cache_dir ufs /var/spool/squid 700 32 512
http_port 3128 transparent
icp_port 3130
cache_peer localhost.home.nl parent 8080 0 default
acl HOME dstdomain .home.nl
always_direct allow all
never_direct allow all
Parte de las trazas del fichero cache.log son las siguientes:
2008/06/10 18:26:18| Accepting proxy HTTP connections at 0.0.0.0, port 3128, FD 13.
2008/06/10 18:26:18| commBind: Cannot bind socket FD 14 to *:3128: (98) Address already in use
No entiendo porque dice address already in use porque no se está usando.
En internet he encontrado que había que ejecutar lo siguiente (lo he ejecutado y nada):
#!/bin/sh
# ------------------------------------------------------------------------------------
# See URL: http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html
# (c) 2006, nixCraft under GNU/GPL v2.0+
# -------------------------------------------------------------------------------------
# squid server IP
SQUID_SERVER="192.168.240.23"
# Interface connected to Internet
INTERNET="eth0"
# Interface connected to LAN
LAN_IN="eth0"
# Squid port
SQUID_PORT="3128"
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
#modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
Valora esta pregunta


0