Squid with MySQL user authentication

Valic —  December 7, 2011 — 3 Comments

Step1. Squid3 install.

apt-get install squid3

Step2. Rename the original squid.conf for backup:

mv /etc/squid3/squid.conf /etc/squid3/squid.conf.back

Step3. Create a new custom file squid.conf:

nano /etc/squid3/squid.conf

and paste the following content:

http_port 3128 transparent
acl localhost src
http_access allow localhost
cache_dir ufs /var/spool/squid3 7000 16 256
auth_param basic program /usr/lib/squid3/squid_db_auth --user userproxy --password parolaproxi --plaintext --persist
auth_param basic children 5
auth_param basic realm This is a welcome message that will me displayed to each user.
auth_param basic credentialsttl 1 minute
auth_param basic casesensitive off
acl db-auth proxy_auth REQUIRED
http_access allow db-auth
http_access allow localhost
http_access deny all

Step4. We will go now to the MySQL and create the database:

mysql -p

Enter the password to log into mysql server. and then create the squid database:

create database squid;
grant select on squid.* to squid_user@localhost identified by 'squid_password';

Create tables in squid database:

use squid;
CREATE TABLE `passwd` (
`user` varchar(32) NOT NULL default '',
`password` varchar(35) NOT NULL default '',
`enabled` tinyint(1) NOT NULL default '1',
`fullname` varchar(60) default NULL,
`comment` varchar(60) default NULL,
PRIMARY KEY (`user`)

Step5. Now create a test user:

insert into passwd values('testuser','test',1,'Test User','for testing ');

Alternatively you can add users with phpMyAdmin.

NOTE:  testuser is the username that appears in the login window, test is the password, 1 tell us thet the account is active, full name is Test User and the comment is testing .



Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

3 responses to Squid with MySQL user authentication

  1. Neelim Sahariah March 19, 2013 at 19:18

    Hi, i am trying to use mysql authenication on ubuntu 12.10 and it is not working.

    the cache .log file says

    Can’t open –plaintext: No such file or directory at /usr/lib/squid3/squid_db_auth line 176

    Please help me.

  2. Please check again the guide. There was a typo, the correct command is this:

    auth_param basic program /usr/lib/squid3/squid_db_auth --user userproxy --password parolaproxi --plaintext --persist

  3. If you used http_port 3128 transparent you not authorized. it is problem squid.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.