Proxy server, saya menggunakan Fedora Core 4 (Linux version 2.6.11-1.1369_FC4)
Dengan menggunakan 2 Ethernet Card
etho menuju ISP, menggunakan konfigurasi DHCp untuk mendapat kan publik IP dari ISP.
eth1 menuju LAN kantor yang saya set statik, dengan konfigurasi sebagai berikut
Click To Expand
[root@localhost ~]# nano /etc/sysconfig/network-scripts/ifcfg-eth1 [Enter]
IPV6INIT=no
ONBOOT=yes
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
DEVICE=eth1
HWADDR=00:1b:11:66:07:1b
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=192.168.0.254
agar server dapat membagi IP ke client saya menggunakan DHCP server, dengan konfigurasi sebagai berikut
Click To Expand
[root@localhost ~]# nano /etc/dhcpd.conf [Enter]
ddns-update-style none;
ignore client-updates;
default-lease-time 86400; # 10 minutes
max-lease-time 172800; # 2 hours
# option domain-name example;
option domain-name-servers xxx.xxx.xxx.xxx; # isi DNS dari ISP
option broadcast-address 192.168.0.255;
option routers 192.168.0.254;
option subnet-mask 255.255.255.0;
subnet 192.168.0.0 netmask 255.255.255.0
{
range 192.168.0.10 192.168.0.20;
}
[step 1]
terlebih dahulu install squidnya menggunakan "yum install squid"
atau bisa di download http://ftp.riken.go.jp/pub/Linux/fedoralegacy/fedora/4/updates/SRPMS/squid-2.5.STABLE13-1.FC4.src.rpm
setelah itu lakukan instal paket RPM nya
[step 2]
langkah selanjutnya mengedit file squid.conf nya yang terletak di /etc/squid
konfigurasi yang saya punya :
Click To Expand
# WELCOME TO SQUID 2
# ------------------
#
# This is the default Squid configuration file. You may wish
# to look at the Squid home page (http://www.squid-cache.org/)
# for the FAQ and other documentation.
#
# The default Squid config file shows what the defaults for
# various options happen to be. If you don't need to change the
# default, you shouldn't uncomment the line. Doing so may cause
# run-time problems. In some cases "none" refers to no default
# setting at all, while in other cases it refers to a valid
# option - the comments for that keyword indicate if this is the
# case.
#
http_port 3128 8080
# OPTIONS WHICH AFFECT THE CACHE SIZE
# -------------------------------------------
# TAG: cache_mem (bytes)
cache_mem 64 MB
# TAG: ipcache_size (number of entries)
# TAG: ipcache_low (percent)
# TAG: ipcache_high (percent)
# The size, low-, and high-water marks for the IP cache.
#
#Default:
# ipcache_size 1024
# ipcache_low 90
# ipcache_high 95
ipcache_size 4096
ipcache_low 90
ipcache_high 95
# TAG: cache_replacement_policy
cache_replacement_policy heap LFUDA
# TAG: memory_replacement_policy
memory_replacement_policy heap LFUDA
# LOGFILE PATHNAMES AND CACHE DIRECTORIES
# --------------------------------------------------
# TAG: cache_dir
cache_dir diskd /cache1 7200 256 14
cache_dir diskd /cache2 8000 256 25
# TAG: cache_access_log
# Logs the client request activity. Contains an entry for
# every HTTP and ICP queries received. To disable, enter "none".
#
#Default:
# cache_access_log /var/log/squid/access.log
cache_access_log none
# TAG: dns_nameservers
#Default:
# none
# DNS ISP
dns_nameservers 203.130.196.5 202.134.0.155
# TAG: refresh_pattern
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
# ACCESS CONTROLS
# ---------------------------------------------
# TAG: acl
# Defining an Access List
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl jakarta src 202.73.227.0/24
acl mynetwork src 192.168.0.0/255.255.255.0
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
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 Safe_ports port 8080 # http proxy
acl CONNECT method CONNECT
# TAG: http_access
http_access allow manager localhost
http_access deny manager
# Deny requests to unknown ports
http_access deny !Safe_ports
# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports
#http_access allow our_networks
http_access allow jakarta
http_access allow mynetwork
# And finally deny all other access to this proxy
http_access allow localhost
http_access deny all
# TAG: visible_hostname
visible_hostname proxyku
# HTTPD-ACCELERATOR OPTIONS
# -----------------------------------------------
# TAG: httpd_accel_host
# TAG: httpd_accel_port
httpd_accel_host virtual
httpd_accel_port 80
# TAG: httpd_accel_with_proxy on|off
httpd_accel_with_proxy on
# TAG: httpd_accel_uses_host_header on|off
httpd_accel_uses_host_header on
konfigurasi yang ditampilkan yang saya sudah ubah dari konfigurasi defaultnya.
[step 3]
Edit file sysctl.conf yang terletak di folder /etc/sysctl.conf
Edit nilai net.ipv4.ip_forward menjadi "1" defaultnya "0"
[step 4]
Setelah melakukan perubahan konfigurasi di sysctl.conf, saatnya menambahkan rule di iptablesnya, dengan melalui perintah :
Click To Expand
[root@localhost ~]# iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT –-to-destination 192.168.0.254:3128
[root@localhost ~]# iptables –t nat –A POSTROUTING –s 192.168.0.0/255.255.255.0 –j MASQUERADE
Maksud dari perintah pertama diatas adalah untuk mengalihkan seluruh paket yang menuju ke ethernet 1 dengan alamat port 80 untuk dialihkan ke port 3128 yang akan menjadi port service dari squid sehingga setiap paket dapat di monitoring.
Sedangkan perintah kedua digunakan untuk “memasking” jaringan LAN yang terdapat dibawah router agar hanya ip publik router Fedora saja yang dikenal di internet.
[step 5]
Kemudian Simpan Konfigurasi iptables dengan mengetik perintah :
[step 6]
Agar konfigurasi selalu dapat berjalan saat mesin ubuntu server dihidupkan ulang atau booting tambahkan baris berikut : iptables-restore /etc/sysconfig/iptables, di dalam file rc.local yang terdapat pada folder /etc/rc.d/rc.local
[step 7]
Kemudian restart service rc.local dengan menggunakan perintah
[step 8]
Ok, client sudah siap mengakses internet, client akan mendapatkan ip dari server, dan sudah siap mengakses internet, tanpa melakukan setting proxi di browser internet.
1 comment:
untuk memonitor akses squid, supaya lebih enak di baca, ketik perintah berikut :
# tail -f /var/log/squid/access.log | awk '{print $3 " --> " $4 " " $7}'
outputnya :
10.11.1.86 --> TCP_MISS/200 http://openx.detik.com/delivery/afr.php?
10.11.1.86 --> TCP_IMS_HIT/304 http://openx.detik.com/delivery/fl.js
10.11.1.86 --> TCP_IMS_HIT/304 http://openx.detik.com/images/665x83_5.swf
Post a Comment