PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Squid3 config Einstellungen



TriggerFm
26.01.11, 18:58
Hallo zusammen,

ich kämpfe seit mittlerweile 2 Wochen mit squid und firewall.

System: Ubuntu Server 9.04

Squid3:
/usr/local/squid/sbin/squid -v
Squid Cache: Version 3.1.10
configure options: '--prefix=/usr/local/squid' '--sysconfdir=/etc/squid' '--enable-ssl' '--enable-icmp' '--enable-linux-netfilter' --with-squid=/home/dl/Desktop/squid/install/squid-3.1.10


Firewall iptables

Ziel:

1. http über Squid von allen Lan Rechnern
(und wenns geht https durchschleusen)

2. von außen per https auf die Webseiten (apache) intern zugreifen


Mein Hauptproblem:
Ich komme mit den Squid Freigabe Reglungen nicht klar.
Ich habe sie mir als Firewall Äquivalent vorgestellt.
Ich befürchte, das sich da eventl. was aufhebt oder ähnliches.
Zuviel freigegeben ist wahrscheinlich dadurch auch im Moment.

Von innerhalb kann ich problemlos über http -> squid surfen.
https lenke ich im Moment direkt per masquerading auf die eth0 um.

Von außerhalb komme ich überhaupt nicht auf meine Seiten.
Weder per http noch https.
Per https aktzeptiert er, wenn ich port:80 transparent ausschalte, wenigstens schon mal die Adresse. Verweigert mir aber den Cache/die ApacheSeite.

Kann mal bitte jemand auf die allow und Cache Regeln schauen und mir zu mehr Klarheit verhelfen?
Vielen Dank!



####### Meine Configs ##############

Aufbau des Netzwerks:

Router:
* externe IP (Port Forwading 80 / 443 auf 10.2.2.1:80/443)
* intern 10.2.2.100

Server
* (eth0) externe IP 10.2.2.1 (zum Router)
* (eth1) zum Lan IP 10.1.1.1

Lan Rechner
* eth0 IP 10.1.1.2

Server, interner Aufbau:
* Squid3 auf externer IP 10.2.2.1 (eth0)
* Apache auf interner IP 10.1.1.1 (eth1)
-------- 10.1.1.1:80 -> mehrere vhosts
-------- 10.1.1.100:443 -> https: vhost
-------- 10.1.1.101:443 -> https: vhost





Firewall Script (das wichtigste)

$FW -F # Regeln
$FW -X # Ketten
$FW -t nat -F
$FW -t nat -X
$FW -t mangle -F
$FW -t mangle -X


## Kette firewall ##
iptables -N firewall

## Loopback ##
iptables -A firewall -i lo -j ACCEPT

## ungueltige Pakete abweisen ##
iptables -A firewall -m state --state INVALID -j DROP

## allg. ##
iptables -A firewall -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A firewall -i eth1 -o eth0 -m state --state NEW -j ACCEPT

## Squid ##
#iptables -A firewall -p tcp -s 10.1.1.0/24 --dport 8080 -d 10.2.2.1 -j ACCEPT
#iptables -A firewall -p tcp -s 10.1.1.0/24 --dport 443 -d 10.2.2.1 -j ACCEPT
iptables -A firewall -p tcp --dport 80 -d 10.2.2.1 -j ACCEPT
iptables -A firewall -p tcp --dport 443 -j -d 10.2.2.1 ACCEPT

## Apache ##
iptables -A firewall -p tcp --dport 80 -j -d 10.1.1.1 ACCEPT
iptables -A firewall -p tcp --dport 443 -j -d 10.1.1.1 ACCEPT

## DNS ##
iptables -A firewall -p tcp --dport 53 -s 10.1.1.0/24 -j ACCEPT
iptables -A firewall -p udp --dport 53 -s 10.1.1.0/24 -j ACCEPT

## Rest ##
##alle TCP-Pakete die bis hier nicht behandelt wurden mit einem TCP-Reset abweisen
iptables -A firewall -p tcp -j REJECT --reject-with tcp-reset

## Ketten injizieren ##
# alle Pakete die bis hier nicht behandlet wurden abweisen
iptables -A firewall -j REJECT

## INPUT in Kette ##
iptables -A INPUT -j firewall

# FORWARD in Kette
iptables -A FORWARD -j firewall

## PREROUTING ##
# Squid
iptables -A PREROUTING -t nat -i eth1 -p tcp -s 10.1.1.0/24 --dport 80 -j DNAT --to 10.2.2.1:80

#iptables -A PREROUTING -t nat -i eth1 -p tcp -s 10.1.1.0/24 --dport 443 -j DNAT --to 10.2.2.1:80 ????

iptables -A PREROUTING -t nat -i eth0 -p tcp -d 10.2.2.1 --dport 443 -j REDIRECT --to-ports 10.2.2.1:443

iptables -A PREROUTING -t nat -i eth0 -p tcp -d 10.2.2.1 --dport 80 -j REDIRECT --to-ports 10.2.2.1:80

## POSTROUTING ##
# Masquerading fuer Pakete die auf ext0 ausgeheno aktivieren
iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE

## IP-Forwarding aktivieren ##
echo 1 > /proc/sys/net/ipv4/ip_forward

######## Firewall ENDE ##############

######## squid.conf ##############
http_port 10.2.2.1:80 transparent

## HTTP ##
#acl wiki_dom dstdomain wiki
#http_access allow wiki_dom
#cache_peer_access vhost1 allow wiki_dom
#cache_peer_access vhost1 deny all

## HTTPS ##
# Wiki
#https_port 10.2.2.1:443 cert=/etc/ssl/ssl-cert.pem key=/etc/ssl/ssl-key.pem options=NO_SSLv2 defaultsite=ApacheMain vhost
#cache_peer 10.1.1.1 parent 80 0 no-query originserver Login=PASS name=vhost1

#acl site1 dstdomain login_page
#cache_peer_access vhost1 allow site1
#http_access allow site1

acl apache rep_header Server ^Apache

acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl squid_host src 10.2.2.1
acl to_squid_host dst 10.2.2.1
acl local_lan src 10.1.1.0/24
acl to_local_lan dst 10.1.1.0/24
acl webserver dst 10.1.1.1
acl extern src 10.2.2.0/24
acl SSL_ports port 443
acl purge method PURFGE
acl https method CONNECT

#cache allow all

http_access allow localhost
http_access allow squid_host
http_access allow to_squid_host
http_access allow local_lan
http_access allow webserver

http_access allow manager localhost
http_access deny manager

http_access allow https SSL_ports
http_access deny !Safe_ports

always_direct allow webserver

http_access allow extern
http_access deny all


cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
emulate_httpd_log on


hierarchy_stoplist cgi-bin ?

cache_dir ufs /var/cache/squid 1024 16 256
cache_mem 128 MB

coredump_dir /usr/local/squid/var/cache

pid_filename /var/run/squid.pid

debug_options ALL,1

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

icp_port 0

acl domains.deny dstdomain regex -i "/etc/squid/domains.deny"
http_access deny domains.deny

visible_hostname xxx.de


######### ENDE Squid ################