S0t4's Blog

Hanya Catatan dan Mencoba Untuk Berbagi

Wednesday, August 5, 2009

Authentikasi user Login di Squid

  Blogger Sejati       Wednesday, August 5, 2009
Tujuannya adalah membatasi akses internet dari client, dimana setiap client yang akses internet nantinya harus input username dan password terlebih dahulu.

Langkah-langkahnya adalah sebagai berikut :

Install Squid, jangan lupa untuk mengenable kan options:

–enable-auth
–enable-basic-auth-helpers

Terus untuk mengecek squid kita sudah support ncsa_auth caranya adalah:
[root@onez ~]# rpm -ql squid | grep ncsa_auth
/usr/lib/squid/ncsa_auth
/usr/share/man/man8/ncsa_auth.8.gz
Kalau keluar seperti itu berarti sudah beres tinggal lanjutkan langkah berikutnya.


Buatlah direktory, dimana direktori ini akan berfungsi sebagai tempat penyimpanan username dan password.

mkdir /usr/lib/squid/ncsa

Buatlah username dan password yang nantinya akan di gunakan untuk authentifikasi login ke squid proxy

htpasswd -c /usr/lib/squid/ncsa/login.auth test
htpasswd /usr/lib/squid/ncsa/login.auth penchot

Baris pertama berarti : membuat file “login.auth” (tempat menaruh username dan password) oleh user “test”
baris kedua berarti : menambahkan username penchot ke dalam login.auth

backup file squid.conf nya terlebih dahulu untuk menjaga hal2 yg tak diinginkan..!!!
# cp /etc/squid/squid.conf /etc/squid/squid.conf.ori

# vi /etc/squid/squid.conf

Edit squid.conf

Tambahkan :

auth_param basic program /usr/lib/squid/ncsa_auth /usr/lib/squid/ncsa/login.auth
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl ncsa_users proxy_auth REQUIRED

http_access allow ncsa_users (Letakkan baris ini sebelum http_access deny all)

Sebagai contoh, ini adalah squid.conf yang saya pakai:

acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl lan src 192.168.0.0/255.255.255.0 #komp lan

auth_param basic program /usr/lib/squid/ncsa_auth /usr/lib/squid/ncsa/login.auth
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl ncsa_users proxy_auth REQUIRED

acl to_localhost dst 127.0.0.0/8
acl PURGE method PURGE
acl SSL_ports port 443 563 10000
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 magic url_regex -i ftp .exe .mp3 .vqf .tar.gz .gz .rpm .zip .rar .avi .mpeg .mpe .mpg .qt .ram .rm .iso .raw .wav
acl CONNECT method CONNECT

http_access allow manager lan
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow PURGE localhost
http_access deny PURGE
http_access allow localhost
http_access allow ncsa_users
http_access allow lan
http_access deny all

kemudian coba jalankan :

squid -k reconfigure

Jika tidak menemukan error, itu berarti konfigurasi squid nya sudah benar, sekarang tinggal test menggunakan browser.
lakukan setting di browsernya agar menggunakan proxy yang tadi kita set, kemudian coba buka salah satu web, misalkan www.google.com, jika muncul kolom username dan password, itu berarti setting auth kita sukses.



Selanjutnya masukkan “username” dan “password” yang kita telah buat tadi, misal:
Username : test
Password : ******

jika kemudian www.google.com nya terbuka, maka itu berarti secara keseluruhan setting yang kita lakukan telah sukses.
logoblog

Thanks for reading Authentikasi user Login di Squid

Previous
« Prev Post

No comments: