Jumat, 31 Desember 2010

Setup Transparent Proxy di CentOS

Tambahkan atau edit file /etc/squid/squid.conf

# Set the maximums size of the object which will be cached
maximum_object_size 8192 KB 

# Set maximum physical RAM to be used for storing objects.
# NOTE: typically squid uses much more RAM then specified so when we said 16 MB then actually it is using around 25 MB RAM.
cache_mem 16 MB


# use to set where to store cache. here it is /cache of size 2048 MB.
# Here 22 and 256 are used to define directory structure so you don't have to touch it.

cache_dir ufs /cache 2048 22 256

acl intranet 192.168.0.0/24
http_access allow intranet

# Memblock situs porno berdasarkan pattern dan domain
acl blacklist_pattern url_regex –i “/etc/squid/blacklist_pattern”
acl blacklist_domain dstdomain “/etc/squid/blacklist_domain”
http_access deny blacklist_pattern intranet
http_access deny blacklist_domain intranet

# Mengijinkan mac address tertentu untuk mengakses tanpa filter
acl mac_free arp 00:01:F3:89:78:A4
http_access allow mac_free

# Give the email of your administrator which can be contacted if anything goes wrong by the users.
cache_mgr you@yourdomain.com
visible_hostname machine-name

http_port 3128 transparent

Mengaktifkan Squid
Mengaktifkan squid ketika boot 
chkconfig squid on

Menjalankan service squid
service squid start

Mengecek status squid
service squid status
 
tail -f /var/log/messages

The tail command should show an error for squid that can help you solve the problem. One common error is that the swap (cache) directory doesn’t exist. To solve this problem, run squid with the -z option to automatically create the directories:
 
/usr/sbin/squid -z

Mengecek alamat yang diakses user
tail -f /var/log/squid/access.log

Setting  iptables untuk mengarahkan trafik ke port 3128

iptables –table nat –append PREROUTING -i eth1 -p tcp –-dport 80 -j REDIRECT -–to-port 3128

service iptables save
service iptables restart

Tidak ada komentar:

Posting Komentar