Friday 29 July 2011

Ubuntu - How to install Proxy Server (Squid)

This is not my, I just copy original the post in here:


A proxy server is a server (a computer system or an application program) which services the requests of its clients by forwarding requests to other servers. A client connects to the proxy server, requesting some service, such as a file, connection, web page, or other resource, available from a different server. The proxy server provides the resource by connecting to the specified server and requesting the service on behalf of the client. A proxy server may optionally alter the client's request or the server's response, and sometimes it may serve the request without contacting the specified server. In this case, it would 'cache' the first request to the remote server, so it could save the information for later, and make everything as fast as possible.

A proxy server that passes all requests and replies unmodified is usually called a gateway or sometimes tunneling proxy.

A proxy server can be placed in the user's local computer or at various points between the user and the destination servers or the Internet.

The following step by step for setup Proxy Server with Linux Ubuntu Server:

Here I assume for the ip address data is as follows:
  • eth0 : 202.102.220.10/29
  • eth1 : 192.168.2.1/24

Now time to install squid:
  • root@server:~# aptitude update && aptitude install squid

move the configuration file squid original:
  • root@server:~# mv /etc/squid/squid.conf /etc/squid/squid.conf_original

make configuration new squid:
  • root@server:~# vim /etc/squid/squid.conf
--by pressing the letter i add the following line--

# WELCOME TO SQUID 2.7.STABLE3
# Author by : udiniqgeek.com
# ---------------------------------------
#
http_port 192.168.2.1:8080 transparent
icp_port 3130
udp_incoming_address 0.0.0.0
udp_outgoing_address 255.255.255.255
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 256 MB
cache_swap_low 90
cache_swap_high 95
connect_timeout 1 minutes
negative_ttl 5 minutes
read_timeout 15 minutes
request_timeout 5 minutes
persistent_request_timeout 1 minutes
client_lifetime 5 day
pconn_timeout 120 seconds
shutdown_lifetime 30 seconds
maximum_object_size 20480 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 4096 KB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024
cache_replacement_policy lru
memory_replacement_policy lru
cache_dir ufs /var/spool/squid 15000 16 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
log_ip_on_direct on
debug_options ALL,1
client_netmask 255.255.255.255
ftp_user Squid@
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
ftp_telnet_protocol on
redirect_children 10
auth_param basic children 10
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
quick_abort_min 16 KB
quick_abort_max 16 KB
quick_abort_pct 95
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 to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563 6667 7000
acl Safe_ports port 80 # http
acl Safe_ports port 81
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https
acl Safe_ports port 70 # ghoper
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 110 # pop3
acl Safe_ports port 4461
acl Safe_ports port 5050
acl CONNECT method CONNECT
http_access allow manager localhost

# LIST OF IP ADDRESS
# ---------------------------------

acl our_network src 192.168.2.1/24

# POLICY ABOUT LAN
# -------------------------------

http_access allow our_network

http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_reply_access allow all
icp_access allow all
miss_access allow all
cache_mgr localhost
visible_hostname localhost

logfile_rotate 10
buffered_logs off
snmp_port 3401
snmp_access allow localhost
snmp_access deny all
snmp_access deny all
coredump_dir /var/spool/squid
ie_refresh on
--save by pressing :wq and Enter--


Then we have to configure transparent proxy, following steps:
  • root@server:~# /sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -J DNAT --to-destination 192.168.2.1:8080

Then we must keep the command routing and transparent proxy over the folder /etc/rc.local, the following steps:
  • root@server:~# vim /etc/rc.local
--by pressing the letter i add the following line--

/sbin/iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to-destination 192.168.2.1:8080

--save by pressing :wq and Enter--


Then please restart your proxy server and proxy server is ready for use:

  • root@server:~# reboot
Source: http://www.udiniqgeek.com/vpn_server.html

No comments:

Post a Comment