Custom Search

Monday, January 28, 2013

How to Install and Configure Proxy Server Authentication with Squid3 in Ubuntu 12

1) 
Install squid3
#sudo apt-get install squid3


2)
Define passwd file for squid
#sudo htpasswd -c /etc/squid3/passwd saju



3)
Locate the auth helper
#ls /usr/lib/squid3/


4)
Edit /etc/squid3/squid.conf file and add following lines.

auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/passwd
auth_param basic children 5
auth_param basic realm saju-Inspiron-N5010
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off

##Define ncsa_auth acl
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users


5)
Restart squid3
#sudo /etc/init.d/squid3 restart


6)
Access Log
#sudo tail -f /var/log/squid3/access.log


7)
Test Proxy authentication with Firefox
Goto Edit --> Preferences -->Advanced --->Network --> Settings
* Select "Manual proxy configuration"
* Http Proxy : 192.168.1.4
* Port : 3128

8)
Test Proxy authentication with python

import urllib2
proxy = urllib2.ProxyHandler({'http': 'http://saju:password@192.168.1.6:3128'})
auth = urllib2.ProxyDigestAuthHandler()
opener = urllib2.build_opener(proxy, auth)
urllib2.install_opener(opener)
conn = urllib2.urlopen('http://python.org')
result = conn.read()
print "========result======", result


9)
Test Proxy authentication with wget

#wget www.google.com

#export http_proxy="http://saju:password@192.168.1.4:3128"
#wget www.google.com

#export http_proxy="http://192.168.1.4:3128"
#wget www.google.com

No comments:

Post a Comment