Jumat, 07 Mei 2010

Install Ubuntu Server 9.10 + Squid Proxy

Booting melalui CD

Select your language : English

Pilih “Install Ubuntu Server

Choose Your anguage (again ) :

Pilih English

Select Your Location :

Pilih Other

Choose a Continent or Region : Asia

Choose a Country, Territory, or Region : Indonesia

Origin of The Keyboard : USA

Keyboard Layout : USA

Network Configuration Method :

autoconfiguration

autoconfiguration with a DHCP hostname

configure network manually

Pilih “Configure Network Manually

Configure Your Network :

Ip Address : 0.0.0.0

Netmask : 0.0.0.0

Gateway : 0.0.0.0

Name Server Address : 0.0.0.0

Hostname : ( Optional )

Domain Name : ( Optional )

Select a City In Your Time Zone : Jakarta

Partitioning Method :

Guide – Use Entire Disk

Guide – Use Entire Disk and Set Up LVM

Guide – Use Entire Disk and Set Up Encripter LVM

Manual -

Pilih Manual

Partitioning Disk

#1

Primary

40.0 GB

B

F

ReiserFS

/

#2

Logical

2.0 GB

F

Swap

Swap Area

#3

Logical

50.0 GB

F

ReiserFS

/var

#4

Logical

34.0 GB

F

ReiserFS

/squid/cache1

#5

Logical

34.0 GB

F

ReiserFS

/squid/cache2


Setup User and Password

Full Name for The New User : ( Optional )

User Name for Your Account : ( Optional )

Choose a Password for The New User : ( Optional )

Re-Enter Password to Verify : ( Optional )


Choose Software to Install :

Beri tanda [*] pada OpenSSH Server

Finishing Installation

Keluarkan CD dari CD Room, kemudian pilih “Continue” untuk “Reboot

Configure The Network

vi /etc/network/interfaces

dengan konfigurasi sebagai berikut :

 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface
auto eth0
iface eth0 inet static
        address 0.0.0.0
        netmask 0.0.0.0
        network 0.0.0.0
        broadcast 0.0.0.0
        gateway 0.0.0.0

Restart konfigurasi network

/etc/init.d/networking restart

Edit /etc/hosts

vi /etc/host

dengan konfigurasi sebagai berikut :

 
127.0.0.1           localhost.localdomain   localhost
0.0.0.0               server1.example.com     server1
 
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Jalankan dengan perintah :

hostname

hostname –f

Install dan Konfigurasi Squid Proxy
sudo aptitude install squid squid-common
Edit the squid config file.
sudo vi /etc/squid/squid.conf
Set the allowed hosts.
acl internal_network src 192.168.0.0/24 ( 192.168.0.0/24 adalah rentang IP anda.)
http_access allow internal_network

Set the correct permissions.

sudo chown -R proxy:proxy /var/log/squid/
sudo chown proxy:proxy /etc/squid/squid.conf

Restart squid untuk perubahan yang mempengaruhi.
sudo /etc/init.d/squid restart

Sekarang buka browser Anda dan mengatur proxy Anda untuk menunjuk ke server squid baru Anda pada port 3128

Jika ingin menggunakan otentikasi dengan proxy maka perlu menginstal utilitas apache2

sudo aptitude install squid squid-common apache2-utils

Edit file konfigurasi squid ( Squid.conf )
sudo vi /etc/squid/squid.conf
Mengatur parameter otentikasi dan acl

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid.passwd
auth_param basic children 5

auth_param basic realm NFYE Squid proxy-caching web_server
auth_param basic credentialsttl 3 hours
auth_param basic casesensitive off

acl users proxy_auth REQUIRED

acl sectionx proxy_auth REQUIRED

http_access allow users

Konfigurasi Squid.conf
acl all src 0.0.0.0/0.0.0.0
acl internal_network src 0.0.0.0/0
acl users proxy_auth REQUIRED
acl manager proto cache_object
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 # https, snews
acl SSL_ports port 873 # rsync
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 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl sectionx proxy_auth REQUIRED
acl purge method PURGE
acl CONNECT method CONNECT
acl all src 0.0.0.0/0.0.0.0
acl internal_network src 192.168.0.0/24
acl users proxy_auth REQUIRED
acl manager proto cache_object
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 # https, snews
acl SSL_ports port 873 # rsync
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 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl sectionx proxy_auth REQUIRED
acl purge method PURGE
acl CONNECT method CONNECT src 192.168.0.0/24
acl users proxy_auth REQUIRED
acl manager proto cache_object
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 # https, snews
acl SSL_ports port 873 # rsync
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 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl sectionx proxy_auth REQUIRED
acl purge method PURGE
acl CONNECT method CONNECT

http_access allow manager localhost localhost
http_access allow users
http_access allow internal_network
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
http_reply_access allow all
icp_access allow all

Jika Anda ingin mengarahkan semua lalu lintas HTTP melalui proxy tanpa perlu mengatur proxy secara manual dalam semua aplikasi anda anda perlu menambahkan beberapa aturan

iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.0.1:3128
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128