BREAKING NEWS
Lazada Indonesia

Tips and Trick

Category 6

Category 7

March 15, 2010

Proxy Server with Squid

For some colleagues who want to make a proxy server with Linux, or for younger siblings CAD Computer Science who will try to learn to make a proxy, I wanted to share my little experience in making the proxy use Linux. Although many software to create a proxy server, I chose squid because the package has been include in the distro I use (Fedora Core) and almost half of the proxy server using squid Linux. For hardware specifications that I use, can be seen in the article Proxy Server in my work. Proxy server using squid version 2.6-12 on Fedora Core 6 distro that I enable as:
1. Saving web pages in proxy to speed up Internet access.
2. Internet access control based on IP Address. Using 2 different networks (as well as enable my router - the IP Forwarding), for this, I use 3 NICs on the server 1.
3. Blacklist banned sites list manually.
4. Limiting the size of the downloaded files with certain extension and apply only at certain hours.
5. Error messages in the format Indonesian.
6. Rule to allow internet access only certain protocols.
The steps I did:
1. Install applications squid
2. Edit the configuration file squid
3. Create directories and files to blacklist blacklists manually
4. Create directories and files for error messages in Indonesian
5. Check the firewall configuration is applied in the proxy
6. Run its service
7. Test the configuration in the proxy and client
Squid configuration file: / etc / squid / squid.conf (my version)
# SQUID 2.6.STABLE12
# Author by: http://fxekobudi.net
# OPTION NETWORKS
# --------------------------
http_port 3128
icp_port 0
# OPTION CACHE SIZE
# -----------------------
cache_mem 256 MB
cache_swap_low 94
cache_swap_high 96
maximum_object_size 16,384 KB
4 KB minimum_object_size
maximum_object_size_in_memory 2048 KB
fqdncache_size 1024
cache_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
# LOG AND CACHE DIRECTORIES
# ----------------------
cache_dir aufs / var / spool / squid 9000 16 256
access_log / var / log / squid / access.log squid
cache_log / var / log / squid / cache.log
cache_store_log none
# TUNING CACHE PROXY
# ----------------------
refresh_pattern ^ ftp:1440 20% 10080
refresh_pattern ^ gopher: 1440 0% 1440
refresh_pattern. 0 20% 4320
1 minutes negative_ttl
# TIMEOUT
# ----------------------
half_closed_clients off
# -------------
# Block forbidden sites (blacklist) manually
# -------------
acl noblacklist dstdomain "/ etc / squid / blacklists / no-blacklist.txt"
url_regex katablacklist acl-i "/ etc / squid / blacklists / word-blacklist.txt"
acl domainblacklist dstdomain "/ etc / squid / blacklists / domain-blacklist.txt"
ipblacklist acl dst "/ etc / squid / blacklists / ip-blacklist.txt"
tdkbebasdownload time 08:00-13:00 acl
# ACCESS CONTROL
# ----------------------
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
to_localhost acl dst 127.0.0.0 / 8
port 443 acl SSL_ports
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
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 # http multiling
acl CONNECT method CONNECT
# -------------
# List of IP addresses
# -------------
lab1 acl src 192.168.254.1-192.168.254.40/255.255.255.255
staff acl it src-192.168.254.41-192.168.254.42/255.255.255.255
lab2 acl src 192.168.254.43-192.168.254.44/255.255.255.255
ruang1 acl src 192.168.1.1-192.168.1.8/255.255.255.255
ruang2 acl src 192.168.1.11-192.168.1.17/255.255.255.255
# -------------
# Block manually banned sites
# -------------
http_access allow noblacklist
http_access deny katablacklist
http_access deny domainblacklist
http_access deny ipblacklist
http_access allow manager localhost
http_access deny manager
# -------------
# Rule which I apply
# -------------
http_access allow lab1
http_access allow staff-it
http_access allow lab2
http_access allow ruang1
http_access allow ruang2
url_regex magic_words2 acl-i ftp. exe. mp3. vqf. tar.gz. gz. tar.bz2. bz2. rpm. zip. rar. avi. mpeg. mpe. mpg. qt. ram. rm. raw. wav. iso
# Cancel download if file is bigger than 2 MB = 2000 × 1024 bytes = 2,048,000 bytes
reply_body_max_size 2048000 allow magic_words2 tdkbebasdownload
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
# PARAMETER ADMINISTRATOR
# ----------------------
cache_mgr fxekobudi@gmail.com
cache_effective_user squid
cache_effective_group squid
visible_hostname proxy.fxekobudi.local
# MESSAGE ERROR IN INDONESIAN
# -----------------------
error_directory / usr / share / squid / errors / Indonesian
In order to manually blacklist functionality that can be used, make a directory containing the files mentioned in the blacklist manually:
# Mkdir / etc / squid / blacklist
# Cd / etc / squid / blacklist /
# Vim no-blacklist.txt
# Vim word blacklist.txt
# Vim domain-blacklist.txt
# Vim ip-blacklist.txt
Minimal included one item for each of these files, because if not, then when we see the error log right after the service squid run, there will be no error message found in the file items ...
In addition, I also include a configuration for error message from squid proxy in the form of Indonesian, so that users at my workplace is easier to understand the point ... The idea of this error message and then became my inspiration when configuring squidGuard to redirect to a file which leads me deliberately created in root directory of the Web proxy server.
To do this, just stay copykan Error messages in English to the directory where error messages in Indonesian language.
# Cp / usr / share / squid / errors / Home / usr / share / squid / errors / Indonesian
trus translate home files ...
To perform its service, simply use the command:
# / Sbin / service squid start
Oh yes, you also need to add in the firewall configuration to use Iptable client is allowed access to the Internet through a proxy, the proxy client requests to the registered IP address is allowed through the port 3128 (or 8080) depending on the configuration you use ... I so remember the first time try, the internet connection on the server proxy pake udah road, but kok ngga clientnya can access, eh emang client was not allowed access to the IP address and port proxy ... Hehe. To get access to the proxy, it iptable rule for the file / etc / sysconfig / iptables must include this rule: (I use a firewall configuration innate Fedora Core)
-A RH-Firewall-1-INPUT-m state - state NEW-m tcp-p tcp - dport 3128-j ACCEPT
To implement IP forwarding, I edit the file / etc / sysctl.conf and gives value 1 (enable) for direktive:
net.ipv4.ip_forward = 0 becomes net.ipv4.ip_forward = 1
This proxy configuration I use some of my workplace (and schooling YBHK Tarsisius

Post a Comment

 
Copyright © 2013 Just Scribble Hand
JSH