How to Configure Squid Proxy for LDAP Authentication on CentOS 6.2 using squid_ldap_auth

In server administration, configuring a proxy server to go through LDAP (Lightweight Directory Access Protocol) authentication can be a challenging task. This tutorial aims to simplify this process for CentOS 6.2 users by using the squid_ldap_auth module that comes with the Squid proxy server.

The Squid proxy server plays a dual role as a caching proxy server between the user and the web, while the 389 Directory Server is an enterprise-class open source LDAP server for Linux. This tutorial assumes that you have both the 389 Ldap Directory server and Squid proxy configured.

The benefits of configuring Squid proxy for LDAP authentication are manifold. It enhances the security of your server by ensuring only authenticated users can access the internet. It also allows for better control and monitoring of internet usage.

Step 1: Modify the Squid Configuration File

The first step in configuring Squid proxy for LDAP authentication is to add certain lines to your squid.conf file. These lines specify the base DN (Distinguished Name) for LDAP authentication and set the necessary access control lists (ACLs).

The commands to be added are as follows:

auth_param basic program /usr/lib/squid/squid_ldap_auth -b "dc=ehowstuff,dc=local" -f "uid=%s" -h ldap.ehowstuff.local
acl ldapauth proxy_auth REQUIRED
http_access allow ldapauth
http_access deny all

Here, the “auth_param” command specifies the base DN for LDAP authentication. The “acl” command creates an access control list named “ldapauth”, and the “http_access” commands allow access for LDAP authenticated users and deny access for all others.

The “http_access deny all” command is optional and depends on your configuration.

Next, open the squid.conf file and modify it as shown in the tutorial. This involves adding your internal network to the “acl” command and specifying the surfing hours and bad websites.

..
..
..
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
acl ehowstuff.com src 192.168.1.0/24    # Your internal network

acl SSL_ports port 443
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         # multiling http
acl CONNECT method CONNECT


#Specifies the base DN for LDAP authentication :
auth_param basic program /usr/lib/squid/squid_ldap_auth -b "dc=ehowstuff,dc=local" -f "uid=%s" -h ldap.ehowstuff.local
acl ldapauth proxy_auth REQUIRED
http_access allow ldapauth


#Add this at the bottom of the ACL Section
#
acl surfing_hours time M T W H F 17:00-24:00
acl Bad_Websites  dstdomain "/etc/squid/web/Bad_Websites.squid"

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Only allow cachemgr access from ehowstuff.com
http_access allow ehowstuff.com surfing_hours !Bad_Websites
http_access deny Bad_Websites
http_access deny ehowstuff.com
..
..
..

Step 2: Configure the Proxy Settings in the Browser

After modifying the squid.conf file, you need to configure the proxy settings in your browser. The proxy IP, domain/hostname, and port need to be specified. Once this is done, the browser that was configured with the proxy setting will prompt for LDAP authentication.

Proxy ip : 192.168.1.44
Domain/Hostname : proxy.ehowstuff.local 
Port : 3128

Step 3: Complete the Squid Configuration

The final step is to complete the Squid configuration by adding the necessary commands to the squid.conf file. This includes specifying the local networks from where browsing should be allowed, denying access to certain unsafe ports, and setting the port where Squid listens.

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
acl ehowstuff.com src 192.168.1.0/24    # Your internal network

acl SSL_ports port 443
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         # multiling http
acl CONNECT method CONNECT


#Specifies the base DN for LDAP authentication :
auth_param basic program /usr/lib/squid/squid_ldap_auth -b "dc=ehowstuff,dc=local" -f "uid=%s" -h ldap.ehowstuff.local
acl ldapauth proxy_auth REQUIRED
http_access allow ldapauth


#Add this at the bottom of the ACL Section
#
acl surfing_hours time M T W H F 17:00-24:00
acl Bad_Websites  dstdomain "/etc/squid/web/Bad_Websites.squid"

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Only allow cachemgr access from ehowstuff.com
http_access allow ehowstuff.com surfing_hours !Bad_Websites
http_access deny Bad_Websites
http_access deny ehowstuff.com



# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

After completing these steps, you will have successfully configured Squid proxy for LDAP authentication on CentOS 6.2.

See also  How to Setup a Login Banner on a Linux system

Conclusion

In summary, configuring Squid proxy for LDAP authentication on CentOS 6.2 involves modifying the squid.conf file, configuring the proxy settings in your browser, and completing the Squid configuration. This process enhances server security and allows for better control and monitoring of internet usage.

We hope this tutorial has been helpful in guiding you through the process.

For more information on proxy servers, you can visit our comprehensive guide on the best proxy servers. If you’re interested in learning more about the Squid proxy server and its features, benefits, and functions, check out our detailed post on Squid Proxy Server Explained.

See also  How to Install wget on CentOS 6.2

If you have any comments or questions, feel free to leave them below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *