{"id":17259,"date":"2023-07-10T21:50:06","date_gmt":"2023-07-10T21:50:06","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=17259"},"modified":"2023-07-04T22:15:25","modified_gmt":"2023-07-04T22:15:25","slug":"how-to-setup-squid-as-a-caching-proxy-with-kerberos-authentication","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-setup-squid-as-a-caching-proxy-with-kerberos-authentication\/","title":{"rendered":"How to Setup Squid as a Caching Proxy with Kerberos Authentication"},"content":{"rendered":"<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-1024x768.jpg\" alt=\"How to Setup Squid as a Caching Proxy with Kerberos Authentication\" width=\"1024\" height=\"768\" class=\"alignnone size-large wp-image-17260 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-1024x768.jpg 1024w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-300x225.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-1536x1152.jpg 1536w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-2048x1536.jpg 2048w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-128x96.jpg 128w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-420x315.jpg 420w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-540x405.jpg 540w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-720x540.jpg 720w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-960x720.jpg 960w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-1140x855.jpg 1140w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-1320x990.jpg 1320w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/07\/How-to-Setup-Squid-as-a-Caching-Proxy-with-Kerberos-Authentication-1440x1080.jpg 1440w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/p>\n<p>Setting up a proxy server can be a complex task, especially when it involves authentication and caching. However, the benefits of having a proxy server in place are numerous. It can help improve your network&#8217;s performance, provide a layer of security, and even manage internet access for users. One of the most popular proxy server software is Squid, which can be configured as a caching proxy that authenticates users to an Active Directory (AD) using Kerberos.<\/p>\n<p>In this tutorial, we will guide you through the process of setting up Squid as a caching proxy with Kerberos authentication on a Red Hat Enterprise Linux server. This configuration ensures that only authenticated users can use the proxy, enhancing the security of your network.<\/p>\n<p>Before we begin, it&#8217;s important to note that this tutorial assumes that the server on which you want to install Squid is a member of the <a href=\"https:\/\/ubuntu.com\/server\/docs\/samba-active-directory\" rel=\"noopener\" target=\"_blank\">AD domain<\/a>.<\/p>\n<p>By following this guide, you will be able to leverage the benefits of a <a href=\"https:\/\/webhostinggeeks.com\/best\/proxy-servers\/\">proxy server<\/a> and enhance the security and performance of your network.<\/p>\n<p>Let&#8217;s get started!<\/p>\n<h2>Step 1: Install the Required Packages<\/h2>\n<p>The first step in setting up Squid as a caching proxy with Kerberos authentication is to install the necessary packages. In this case, you will need to install the Squid and krb5-workstation packages. You can do this by running the following command:<\/p>\n<pre>\r\n# yum install squid krb5-workstation\r\n<\/pre>\n<h2>Step 2: Authenticate as the AD Domain Administrator<\/h2>\n<p>After installing the required packages, you need to authenticate as the AD domain administrator. You can do this by running the following command:<\/p>\n<pre>\r\n# kinit administrator@AD.EXAMPLE.COM\r\n<\/pre>\n<h2>Step 3: Create a Keytab for Squid<\/h2>\n<p>Next, you need to create a keytab for Squid and store it in the \/etc\/squid\/HTTP.keytab file. You can do this by running the following commands:<\/p>\n<pre>\r\n# export KRB5_KTNAME=FILE:\/etc\/squid\/HTTP.keytab\r\n# net ads keytab CREATE -U administrator\r\n<\/pre>\n<h2>Step 4: Add the HTTP Service Principal to the Keytab<\/h2>\n<p>After creating the keytab for Squid, you need to add the HTTP service principal to the keytab. You can do this by running the following command:<\/p>\n<pre>\r\n# net ads keytab ADD HTTP -U administrator\r\n<\/pre>\n<h2>Step 5: Set the Owner of the Keytab File to the Squid User<\/h2>\n<p>Next, you need to set the owner of the keytab file to the squid user. You can do this by running the following command:<\/p>\n<pre>\r\n# chown squid \/etc\/squid\/HTTP.keytab\r\n<\/pre>\n<h2>Step 6: Verify the Keytab File<\/h2>\n<p>Optionally, you can verify that the keytab file contains the HTTP service principal for the fully-qualified domain name (FQDN) of the proxy server. You can do this by running the following command:<\/p>\n<pre>\r\n# klist -k \/etc\/squid\/HTTP.keytab\r\n<\/pre>\n<p>The output should include the HTTP service principal for the FQDN of the proxy server.<\/p>\n<h2>Step 7: Edit the \/etc\/squid\/squid.conf File<\/h2>\n<p>The next step is to edit the \/etc\/squid\/squid.conf file. This file contains the configuration settings for Squid. You need to add the following configuration entry to the top of \/etc\/squid\/squid.conf to configure the negotiate_kerberos_auth helper utility:<\/p>\n<pre>\r\nauth_param negotiate program \/usr\/lib64\/squid\/negotiate_kerberos_auth -k \/etc\/squid\/HTTP.keytab -s HTTP\/proxy.ad.example.com@AD.EXAMPLE.COM\r\n<\/pre>\n<p>This command configures the negotiate_kerberos_auth helper utility with the path to the keytab file and the Kerberos principal that Squid uses.<\/p>\n<h2>Step 8: Configure Squid to Allow Only Authenticated Users<\/h2>\n<p>Next, you need to add the following ACL and rule to configure that Squid allows only authenticated users to use the proxy:<\/p>\n<pre>\r\nacl kerb-auth proxy_auth REQUIRED\r\nhttp_access allow kerb-auth\r\n<\/pre>\n<p>These settings should be specified before the http_access deny all rule.<\/p>\n<h2>Step 9: Disable Bypassing the Proxy Authentication<\/h2>\n<p>To enhance the security of your network, you should disable bypassing the proxy authentication from IP ranges specified in localnet ACLs. You can do this by removing the following rule:<\/p>\n<pre>\r\nhttp_access allow localnet\r\n<\/pre>\n<h2>Step 10: Configure the Ports<\/h2>\n<p>By default, the configuration contains the http_access deny !Safe_ports rule that defines access denial to ports that are not defined in Safe_ports ACLs. If users should be able to use the HTTPS protocol also on other ports, add an ACL for each of these ports:<\/p>\n<pre>\r\nacl SSL_ports port port_number\r\n<\/pre>\n<p>Update the list of acl Safe_ports rules to configure to which ports Squid can establish a connection. For example, to configure that clients using the proxy can only access resources on port 21 (FTP), 80 (HTTP), and 443 (HTTPS), keep only the following acl Safe_ports statements in the configuration:<\/p>\n<pre>\r\nacl Safe_ports port 21\r\nacl Safe_ports port 80\r\nacl Safe_ports port 443\r\n<\/pre>\n<h2>Step 11: Configure the Cache<\/h2>\n<p>Next, you need to configure the cache type, the path to the cache directory, the cache size, and further cache type-specific settings in the cache_dir parameter:<\/p>\n<pre>\r\ncache_dir ufs \/var\/spool\/squid 10000 16 256\r\n<\/pre>\n<p>With these settings, Squid uses the ufs cache type, stores its cache in the \/var\/spool\/squid\/ directory, the cache grows up to 10000 MB, it creates 16 level-1 sub-directories in the \/var\/spool\/squid\/ directory, and creates 256 sub-directories in each level-1 directory.<\/p>\n<h2>Step 12: Open the 3128 Port in the Firewall<\/h2>\n<p>To allow traffic to pass through the proxy server, you need to open the 3128 port in the firewall. You can do this by running the following commands:<\/p>\n<pre>\r\n# firewall-cmd --permanent --add-port=3128\/tcp\r\n# firewall-cmd --reload\r\n<\/pre>\n<h2>Step 13: Start and Enable the Squid Service<\/h2>\n<p>Finally, you need to start the squid service and enable it to start automatically when the system boots. You can do this by running the following commands:<\/p>\n<pre>\r\n# systemctl start squid\r\n# systemctl enable squid\r\n<\/pre>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">yum install squid krb5-workstation<\/span>: This command installs the necessary packages for setting up Squid as a caching proxy with Kerberos authentication.<\/li>\n<li><span class=\"fw-bold\">kinit administrator@AD.EXAMPLE.COM<\/span>: This command authenticates you as the AD domain administrator.<\/li>\n<li><span class=\"fw-bold\">export KRB5_KTNAME=FILE:\/etc\/squid\/HTTP.keytab<\/span> and <span class=\"fw-bold\">net ads keytab CREATE -U administrator<\/span>: These commands create a keytab for Squid and store it in the \/etc\/squid\/HTTP.keytab file.<\/li>\n<li><span class=\"fw-bold\">net ads keytab ADD HTTP -U administrator<\/span>: This command adds the HTTP service principal to the keytab.<\/li>\n<li><span class=\"fw-bold\">chown squid \/etc\/squid\/HTTP.keytab<\/span>: This command sets the owner of the keytab file to the squid user.<\/li>\n<li><span class=\"fw-bold\">klist -k \/etc\/squid\/HTTP.keytab<\/span>: This command verifies that the keytab file contains the HTTP service principal for the fully-qualified domain name (FQDN) of the proxy server.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this tutorial, we walked you through the process of setting up Squid as a caching proxy with Kerberos authentication on a Red Hat Enterprise Linux server. This configuration enhances the security of your network by ensuring that only authenticated users can use the proxy. It also improves your network&#8217;s performance by caching frequently accessed content.<\/p>\n<p>We hope you found this guide helpful. If you have any questions or comments, please feel free to leave them below.<\/p>\n<p>For more information on proxy servers and web servers, you can check out our articles on <a href=\"https:\/\/webhostinggeeks.com\/blog\/squid-proxy-server-features-functions-benefits\/\">Squid Proxy Server<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/best\/proxy-sites\/\">Proxy Sites<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">Web Servers<\/a>, and <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache HTTP Server<\/a>.<\/p>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is a keytab file and why is it necessary for Squid?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<span itemprop=\"text\">A keytab file is a key table file that stores pairs of Kerberos principals and encrypted keys. It is used by Squid to authenticate to the Kerberos Key Distribution Center (KDC) without the need for entering a password. This is crucial for the automatic startup of the Squid service.<\/span>\n<\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why do we need to open the 3128 port in the firewall?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<span itemprop=\"text\">Port 3128 is the default port used by Squid for listening to incoming proxy requests. Opening this port in the firewall allows traffic to pass through the proxy server, enabling clients to connect to the internet through the Squid proxy.<\/span>\n<\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the role of the negotiate_kerberos_auth helper utility in Squid?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<span itemprop=\"text\">The negotiate_kerberos_auth helper utility in Squid is used to authenticate users to an Active Directory using Kerberos. It verifies the Kerberos tickets presented by the clients and informs Squid whether the authentication was successful or not.<\/span>\n<\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the benefit of setting up Squid as a caching proxy?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<span itemprop=\"text\">Setting up Squid as a caching proxy can significantly improve the performance of your network. It does this by storing frequently accessed web content and serving it to clients from the cache. This reduces bandwidth usage and speeds up web access for users.<\/span>\n<\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Can I use a different port for Squid instead of the default 3128?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<span itemprop=\"text\">Yes, you can configure Squid to listen on a different port. This can be done by changing the &#8216;http_port&#8217; directive in the Squid configuration file. However, you must also update your firewall rules and client configurations to use the new port.<\/span>\n<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Setting up a proxy server can be a complex task, especially when it involves authentication and caching. However, the benefits of having a proxy server in place are numerous. It&#8230;<\/p>\n","protected":false},"author":6,"featured_media":17260,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1057],"tags":[2076,2089,2100,1678,1793],"class_list":["post-17259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-squid-server","tag-cache","tag-configuration","tag-kerberos","tag-proxy","tag-squid"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/17259","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=17259"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/17259\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/17260"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=17259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=17259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=17259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}