{"id":678,"date":"2012-01-20T11:55:11","date_gmt":"2012-01-20T18:55:11","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=678"},"modified":"2012-01-20T12:58:52","modified_gmt":"2012-01-20T19:58:52","slug":"how-to-blockallow-proxy-access-via-squid-proxy-using-ads-authentication","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=678","title":{"rendered":"How to block\/allow proxy access via squid proxy using ADS authentication and group membership."},"content":{"rendered":"<p>The following procedures were used on RedHat Enterprise Linux 5.x.<\/p>\n<p>The following previous post outlined how to get the linux server joined to domain and supporting ADS authentication.  This link also contains information for RHEL6.x in the comments as well :<\/p>\n<p><a href=\"http:\/\/jim-zimmerman.com\/?p=356\">Howto Join An Active Directory Server using RHEL5.x\/CentOS5.x and Samba 3.0.x<\/a><\/p>\n<p>The key is getting the \/etc\/squid\/squid\/conf right.  I have included the entire configuration used.  A lot of the options are not required in all situations.  I have a number of things going on here.  Many of which I could clean up and make better, but I wanted to leave them in here because I know this configuration works.  I actually have three proxy servers (two peers) in the configuration.  The configuration forwards the requests to one of the two peers based upon the site accessed.  This is probably not required for most deployments.<\/p>\n<p><code># cat \/etc\/squid\/squid.conf<\/p>\n<p># Port squid listens on<br \/>\nhttp_port 3128<br \/>\n...<br \/>\nhierarchy_stoplist cgi-bin ?<\/p>\n<p>acl QUERY urlpath_regex cgi-bin \\?<br \/>\ncache deny QUERY<\/p>\n<p>acl apache rep_header Server ^Apache<br \/>\nbroken_vary_encoding allow apache<\/p>\n<p>cache_dir null \/tmp<\/p>\n<p>access_log \/var\/log\/squid\/access.log common<\/p>\n<p># To support ADS credentials for access.<br \/>\nauth_param ntlm program \/usr\/bin\/ntlm_auth --helper-protocol=squid-2.5-ntlmssp<br \/>\nauth_param ntlm children 10<br \/>\nauth_param ntlm keep_alive on<\/p>\n<p># Begin Group<br \/>\n# To support ADS group membership requirements.<br \/>\nexternal_acl_type WindowsGroup ttl=60 children=5 %LOGIN \/usr\/lib\/squid\/wbinfo_group.pl<br \/>\n# End Group <\/p>\n<p>refresh_pattern ^ftp:\t\t1440\t20%\t10080<br \/>\nrefresh_pattern ^gopher:\t1440\t0%\t1440<br \/>\nrefresh_pattern .\t\t0\t20%\t4320<\/p>\n<p>acl all src 0.0.0.0\/0.0.0.0<br \/>\n# To allow sites that do not work with NTLM.  Created a list of sites that do not seem to work using NTLM<br \/>\n# to exclude from authentication requirement.<br \/>\nacl allowsites url_regex -i \"\/etc\/squid\/allowedsites.acl\"<\/p>\n<p># Begin Group<br \/>\n# ACLs to get ADS group membership.  I have two groups here.  One group has unrestricted access<br \/>\n# and the other limited.  The ADS groups used here are ProxyAccess and ProxyAccessLimited.<br \/>\nacl InWindowsGroup external WindowsGroup ProxyAccess<br \/>\nacl InLimitedWindowsGroup external WindowsGroup ProxyAccessLimited<br \/>\n# End Group <\/p>\n<p># Begin Facebook test.<br \/>\n# These ACLs are set up to manage which users can access Facebook in this instance.<br \/>\n# List of users.<br \/>\nacl UnRestrictedUsers proxy_auth \"\/etc\/squid\/UnRestrictedUsers.acl\"<br \/>\n# List of sites allowed to these users.<br \/>\nacl ExcemptedSites url_regex -i \"\/etc\/squid\/ExcemptedSites.acl\"<br \/>\n# List of managed domains.<br \/>\nacl RestrictedDomains dstdomain \"\/etc\/squid\/RestrictedDomains.acl\"<br \/>\n# End Facebook test.<\/p>\n<p># Begin limited access test.<br \/>\n# This is where the specific restrictions are made for the ProxyAccessLimited users.<br \/>\nacl LimitAllowedSites url_regex -i \"\/etc\/squid\/LimitAllowedSites.acl\"<br \/>\nacl LimitRestrictions dstdomain \"\/etc\/squid\/LimitRestrictions.acl\"<br \/>\n# End store access test.<\/p>\n<p>acl MyACL proxy_auth REQUIRED<br \/>\nacl java browser java<br \/>\nacl java browser Java<\/p>\n<p>acl broken dstdomain .aa.com<br \/>\nheader_access Accept-Encoding deny broken <\/p>\n<p>http_access allow all java<br \/>\nhttp_access allow all allowsites<\/p>\n<p># Begin Group<br \/>\n# This will allow users in the ProxyAccessLimited ADS group access to the sites listed in the<br \/>\n# \/etc\/squid\/LimitAllowedSites.acl file, but access to the sites listed in the \/etc\/squid\/LimitRestrictions.acl<br \/>\n# file.  Note: a \".\" in the LimitRestrictions.acl file will limit the users only to the sites listed in the<br \/>\n# LimitAllowedSites.acl file.<br \/>\nhttp_access allow InLimitedWindowsGroup LimitAllowedSites !LimitRestrictions<br \/>\n# This will allow users in the ProxyAccess ADS group access to any sites, and permits those listed in the<br \/>\n# \/etc\/squid\/UnRestrictedUsers.acl file access to the site listed in the \/etc\/squid\/ExcemptedSites.acl file.<br \/>\nhttp_access allow InWindowsGroup UnRestrictedUsers ExcemptedSites<br \/>\n# This will allow users in the ProxyAccess ADS group access to any sites, except those listed in the<br \/>\n# \/etc\/squid\/ExcemptedSites.acl file.<br \/>\nhttp_access allow InWindowsGroup !ExcemptedSites<br \/>\n# End Group <\/p>\n<p>http_access deny all<br \/>\nnever_direct allow all<br \/>\n# This is where the two peers are defined.<br \/>\ncache_peer <em>myproxy01.domain.com<\/em> parent 80 0 no-query default<br \/>\ncache_peer <em>myproxy02.domain.com<\/em> parent 80 0 no-query default<\/p>\n<p># This determines which peer is going to used based the sites listed in the \/etc\/squid\/RestrictedDomains.acl<br \/>\n# file.<br \/>\ncache_peer_access <em>myproxy01.domain.com<\/em> deny RestrictedDomains<br \/>\ncache_peer_access <em>myproxy02.domain.com<\/em> allow RestrictedDomains<\/p>\n<p>acl manager proto cache_object<br \/>\nacl localhost src 127.0.0.1\/255.255.255.255<br \/>\nacl to_localhost dst 127.0.0.0\/8<br \/>\nacl SSL_ports port 443<br \/>\nacl Safe_ports port 80\t\t# http<br \/>\nacl Safe_ports port 21\t\t# ftp<br \/>\nacl Safe_ports port 443\t\t# https<br \/>\nacl Safe_ports port 70\t\t# gopher<br \/>\nacl Safe_ports port 210\t\t# wais<br \/>\nacl Safe_ports port 1025-65535\t# unregistered ports<br \/>\nacl Safe_ports port 280\t\t# http-mgmt<br \/>\nacl Safe_ports port 488\t\t# gss-http<br \/>\nacl Safe_ports port 591\t\t# filemaker<br \/>\nacl Safe_ports port 777\t\t# multiling http<br \/>\nacl CONNECT method CONNECT<\/p>\n<p>http_access allow manager localhost<br \/>\nhttp_access deny manager<br \/>\nhttp_access deny !Safe_ports<br \/>\nhttp_access deny CONNECT !SSL_ports<br \/>\nhttp_access allow localhost<br \/>\nhttp_access deny all<\/p>\n<p>http_reply_access allow all<\/p>\n<p>icp_access allow all<\/p>\n<p>cache_effective_group squid<\/p>\n<p>coredump_dir \/var\/spool\/squid<\/p>\n<p>memory_pools off<\/p>\n<p>half_closed_clients off<br \/>\n<\/code><\/p>\n<p>The .acl files listed in the configuration are either just a list of usernames (ADS or otherwise), or a list of domains.  In the case of the domains, you can use the following syntax to signify all host for a particular domain:<\/p>\n<p><code>.mydomain.com<br \/>\n<\/code><\/p>\n<p>Below, I have tried to strip out the other things to demonstrate all that is needed to support proxy access via ADS group membership.<\/p>\n<p>Excerpts from \/etc\/squid\/squid.conf:<br \/>\n<code>auth_param ntlm program \/usr\/bin\/ntlm_auth --helper-protocol=squid-2.5-ntlmssp<br \/>\nauth_param ntlm children 10<br \/>\nauth_param ntlm keep_alive on<br \/>\n...<br \/>\n# Begin Group<br \/>\nexternal_acl_type WindowsGroup ttl=60 children=5 %LOGIN \/usr\/lib\/squid\/wbinfo_group.pl<br \/>\n# End Group<br \/>\n...<br \/>\n# Begin Group<br \/>\nacl InWindowsGroup external WindowsGroup ProxyAccess<br \/>\nacl InLocationsWindowsGroup external WindowsGroup ProxyAccessLocations<br \/>\n# End Group<br \/>\n...<br \/>\n# Begin store access test.<br \/>\nacl LocationAllowedSites url_regex -i \"\/etc\/squid\/LocationAllowedSites.acl\"<br \/>\nacl LocationRestrictions dstdomain \"\/etc\/squid\/LocationRestrictions.acl\"<br \/>\n# End store access test.<br \/>\n...<br \/>\nacl MyACL proxy_auth REQUIRED<br \/>\n...<br \/>\n# Begin Group<br \/>\nhttp_access allow InLocationsWindowsGroup LocationAllowedSites !LocationRestrictions<br \/>\nhttp_access allow InWindowsGroup<br \/>\n# End Group<br \/>\n...<\/code><\/p>\n<p>Also, if you want to customize the default access denied page that users receive when they go to a site that they are not permitted to access, you can add you customizations to the \/usr\/share\/squid\/errors\/English\/ERR_ACCESS_DENIED file.  I believe you can do a number of other creative things with error pages, but I have not looked in to that.<\/p>\n<p>If you want to add\/remove sites from the files, you just need to issue a &#8220;<em>service squid reload<\/em>&#8221; to activate the new settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following procedures were used on RedHat Enterprise Linux 5.x. The following previous post outlined how to get the linux server joined to domain and supporting ADS authentication. This link also contains information for RHEL6.x in the comments as well : Howto Join An Active Directory Server using RHEL5.x\/CentOS5.x and Samba 3.0.x The key is [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[83,40,239,48,50,86],"class_list":["post-678","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-ads","tag-centos","tag-groups","tag-linux","tag-redhat","tag-squid"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":4,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":682,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions\/682"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}