Proxy Squid - Ubuntu
Primero, actualizaremos el sistema con
sudo apt update
sudo apt upgrade
Posteriormente, deberemos instalar el proxy squid
sudo apt install squid
Ahora, realizaremos una copia del archivo de configuracion
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original
sudo chmod a-w /etc/squid/squid.conf.original
Y editaremos el fichero de configuracion con
sudo gedit /etc/squid/squid.conf
Y pegaremos el siguiente contenido
# WELCOME TO SQUID 6.10
# ----------------------------
#
# This is the documentation for the Squid configuration file.
# This documentation can also be found online at:
# http://www.squid-cache.org/Doc/config/
#
# You may wish to look at the Squid home page and wiki for the
# FAQ and other documentation:
# http://www.squid-cache.org/
# http://wiki.squid-cache.org/SquidFaq
# http://wiki.squid-cache.org/ConfigExamples
#
#Default:
# ACLs all, manager, localhost, and to_localhost are predefined.
#
#
# Recommended minimum configuration:
#
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
#acl localnet src fc00::/7 # RFC 4193 local private network range
#acl localnet src fe80::/10 # RFC 4291 link-local (directly
plugged) machines
acl ai1 src 192.168.1.0/24
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#Default:
# Deny, unless rules exist in squid.conf.
#
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
http_access allow localhost
http_access allow ai1
# And finally deny all other access to this proxy
http_access allow all
# Squid normally listens to port 3128
http_port 3128
Ahora, iniciaremos el servicio
sudo service squid start
Y comprobaremos el status con
sudo service squid status
Y para probar, deberemos acceder a la configuracion de proxy de nuestro navegador
Y en la puerta de enlace y dns de cliente, agregaremos la misma direccion IP (la del servidor)
Y para bloquear algunos sitios, deberemos añadir unas lineas
acl blacklist1 dstdomain www.cisco.com
http_access deny blacklist1
Ahora, para el proxy transparente, deberemos sin configurar el navegador, con la puerta de enlace del servidor, directamente que nos deje navegar, para ello, deberemos:
# Squid normally listens to port 3128
http_port 3128 transparent
Y deberemos activar algunas reglas:
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 80 -j DNAT --to-destination 192.168.32.111:3128
iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 443 -j DNAT --to-destination 192.168.32.111:3128
Comandos para administrar servidor:
sudo service squid reload
sudo service squid start
systemctl status squid.service
sudo gedit /etc/squid/squid.conf
Comments
Post a Comment