{"id":2469,"date":"2012-03-20T23:46:51","date_gmt":"2012-03-20T15:46:51","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2469"},"modified":"2023-07-04T15:32:53","modified_gmt":"2023-07-04T15:32:53","slug":"how-to-configure-squid-proxy-for-ldap-authentication-on-centos-6-2-using-squid_ldap_auth","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-configure-squid-proxy-for-ldap-authentication-on-centos-6-2-using-squid_ldap_auth\/","title":{"rendered":"How to Configure Squid Proxy for LDAP Authentication on CentOS 6.2 using squid_ldap_auth"},"content":{"rendered":"<p>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.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<h2>Step 1: Modify the Squid Configuration File<\/h2>\n<p>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).<\/p>\n<p>The commands to be added are as follows:<\/p>\n<pre>\r\nauth_param basic program \/usr\/lib\/squid\/squid_ldap_auth -b \"dc=ehowstuff,dc=local\" -f \"uid=%s\" -h ldap.ehowstuff.local\r\nacl ldapauth proxy_auth REQUIRED\r\nhttp_access allow ldapauth\r\nhttp_access deny all\r\n<\/pre>\n<p>Here, the &#8220;auth_param&#8221; command specifies the base DN for LDAP authentication. The &#8220;acl&#8221; command creates an access control list named &#8220;ldapauth&#8221;, and the &#8220;http_access&#8221; commands allow access for LDAP authenticated users and deny access for all others.<\/p>\n<p>The &#8220;http_access deny all&#8221; command is optional and depends on your configuration.<\/p>\n<p>Next, open the squid.conf file and modify it as shown in the tutorial. This involves adding your internal network to the &#8220;acl&#8221; command and specifying the surfing hours and bad websites.<\/p>\n<pre>\r\n..\r\n..\r\n..\r\nacl localnet src 172.16.0.0\/12  # RFC1918 possible internal network\r\nacl localnet src 192.168.0.0\/16 # RFC1918 possible internal network\r\nacl localnet src fc00::\/7       # RFC 4193 local private network range\r\nacl localnet src fe80::\/10      # RFC 4291 link-local (directly plugged) machines\r\nacl ehowstuff.com src 192.168.1.0\/24    # Your internal network\r\n\r\nacl SSL_ports port 443\r\nacl Safe_ports port 80          # http\r\nacl Safe_ports port 21          # ftp\r\nacl Safe_ports port 443         # https\r\nacl Safe_ports port 70          # gopher\r\nacl Safe_ports port 210         # wais\r\nacl Safe_ports port 1025-65535  # unregistered ports\r\nacl Safe_ports port 280         # http-mgmt\r\nacl Safe_ports port 488         # gss-http\r\nacl Safe_ports port 591         # filemaker\r\nacl Safe_ports port 777         # multiling http\r\nacl CONNECT method CONNECT\r\n\r\n\r\n#Specifies the base DN for LDAP authentication :\r\nauth_param basic program \/usr\/lib\/squid\/squid_ldap_auth -b \"dc=ehowstuff,dc=local\" -f \"uid=%s\" -h ldap.ehowstuff.local\r\nacl ldapauth proxy_auth REQUIRED\r\nhttp_access allow ldapauth\r\n\r\n\r\n#Add this at the bottom of the ACL Section\r\n#\r\nacl surfing_hours time M T W H F 17:00-24:00\r\nacl Bad_Websites  dstdomain \"\/etc\/squid\/web\/Bad_Websites.squid\"\r\n\r\n#\r\n# Recommended minimum Access Permission configuration:\r\n#\r\n# Only allow cachemgr access from localhost\r\nhttp_access allow manager localhost\r\nhttp_access deny manager\r\n\r\n# Only allow cachemgr access from ehowstuff.com\r\nhttp_access allow ehowstuff.com surfing_hours !Bad_Websites\r\nhttp_access deny Bad_Websites\r\nhttp_access deny ehowstuff.com\r\n..\r\n..\r\n..<\/pre>\n<h2>Step 2: Configure the Proxy Settings in the Browser<\/h2>\n<p>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.<\/p>\n<pre>\r\nProxy ip : 192.168.1.44\r\nDomain\/Hostname : proxy.ehowstuff.local \r\nPort : 3128\r\n<\/pre>\n<h2>Step 3: Complete the Squid Configuration<\/h2>\n<p>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.<\/p>\n<pre>\r\n#\r\n# Recommended minimum configuration:\r\n#\r\nacl manager proto cache_object\r\nacl localhost src 127.0.0.1\/32 ::1\r\nacl to_localhost dst 127.0.0.0\/8 0.0.0.0\/32 ::1\r\n\r\n# Example rule allowing access from your local networks.\r\n# Adapt to list your (internal) IP networks from where browsing\r\n# should be allowed\r\nacl localnet src 10.0.0.0\/8     # RFC1918 possible internal network\r\nacl localnet src 172.16.0.0\/12  # RFC1918 possible internal network\r\nacl localnet src 192.168.0.0\/16 # RFC1918 possible internal network\r\nacl localnet src fc00::\/7       # RFC 4193 local private network range\r\nacl localnet src fe80::\/10      # RFC 4291 link-local (directly plugged) machines\r\nacl ehowstuff.com src 192.168.1.0\/24    # Your internal network\r\n\r\nacl SSL_ports port 443\r\nacl Safe_ports port 80          # http\r\nacl Safe_ports port 21          # ftp\r\nacl Safe_ports port 443         # https\r\nacl Safe_ports port 70          # gopher\r\nacl Safe_ports port 210         # wais\r\nacl Safe_ports port 1025-65535  # unregistered ports\r\nacl Safe_ports port 280         # http-mgmt\r\nacl Safe_ports port 488         # gss-http\r\nacl Safe_ports port 591         # filemaker\r\nacl Safe_ports port 777         # multiling http\r\nacl CONNECT method CONNECT\r\n\r\n\r\n#Specifies the base DN for LDAP authentication :\r\nauth_param basic program \/usr\/lib\/squid\/squid_ldap_auth -b \"dc=ehowstuff,dc=local\" -f \"uid=%s\" -h ldap.ehowstuff.local\r\nacl ldapauth proxy_auth REQUIRED\r\nhttp_access allow ldapauth\r\n\r\n\r\n#Add this at the bottom of the ACL Section\r\n#\r\nacl surfing_hours time M T W H F 17:00-24:00\r\nacl Bad_Websites  dstdomain \"\/etc\/squid\/web\/Bad_Websites.squid\"\r\n\r\n#\r\n# Recommended minimum Access Permission configuration:\r\n#\r\n# Only allow cachemgr access from localhost\r\nhttp_access allow manager localhost\r\nhttp_access deny manager\r\n\r\n# Only allow cachemgr access from ehowstuff.com\r\nhttp_access allow ehowstuff.com surfing_hours !Bad_Websites\r\nhttp_access deny Bad_Websites\r\nhttp_access deny ehowstuff.com\r\n\r\n\r\n\r\n# Deny requests to certain unsafe ports\r\nhttp_access deny !Safe_ports\r\n\r\n# Deny CONNECT to other than secure SSL ports\r\nhttp_access deny CONNECT !SSL_ports\r\n\r\n# We strongly recommend the following be uncommented to protect innocent\r\n# web applications running on the proxy server who think the only\r\n# one who can access services on \"localhost\" is a local user\r\n#http_access deny to_localhost\r\n\r\n#\r\n# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS\r\n#\r\n\r\n# Example rule allowing access from your local networks.\r\n# Adapt localnet in the ACL section to list your (internal) IP networks\r\n# from where browsing should be allowed\r\n#http_access allow localnet\r\nhttp_access allow localhost\r\n\r\n# And finally deny all other access to this proxy\r\nhttp_access deny all\r\n\r\n# Squid normally listens to port 3128\r\nhttp_port 3128\r\n\r\n# We recommend you to use at least the following line.\r\nhierarchy_stoplist cgi-bin ?\r\n\r\n# Uncomment and adjust the following to add a disk cache directory.\r\n#cache_dir ufs \/var\/spool\/squid 100 16 256\r\n\r\n# Leave coredumps in the first cache dir\r\ncoredump_dir \/var\/spool\/squid\r\n\r\n# Add any of your own refresh_pattern entries above these.\r\nrefresh_pattern ^ftp:           1440    20%     10080\r\nrefresh_pattern ^gopher:        1440    0%      1440\r\nrefresh_pattern -i (\/cgi-bin\/|\\?) 0     0%      0\r\nrefresh_pattern .               0       20%     4320\r\n<\/pre>\n<p>After completing these steps, you will have successfully configured Squid proxy for LDAP authentication on CentOS 6.2.<\/p>\n<h2>Conclusion<\/h2>\n<p>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.<\/p>\n<p>We hope this tutorial has been helpful in guiding you through the process.<\/p>\n<p>For more information on proxy servers, you can visit our comprehensive guide on the <a href=\"https:\/\/webhostinggeeks.com\/best\/proxy-servers\/\">best proxy servers<\/a>. If you&#8217;re interested in learning more about the Squid proxy server and its features, benefits, and functions, check out our detailed post on <a href=\"https:\/\/webhostinggeeks.com\/blog\/squid-proxy-server-features-functions-benefits\/\">Squid Proxy Server Explained<\/a>.<\/p>\n<p>If you have any comments or questions, feel free to leave them below.                                     <\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":6,"featured_media":2471,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1102,2055,1160,1057],"tags":[1178,1244,1253,2089,1536,1546,1678,1793],"class_list":["post-2469","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-389-directory-server","category-centos","category-ldap-linux","category-squid-server","tag-389-directory","tag-centos","tag-centos-6-2","tag-configuration","tag-linux","tag-linux-utilities","tag-proxy","tag-squid"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2469"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2469\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/2471"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}