<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.pl-s
{mso-style-name:pl-s;}
span.pl-s1
{mso-style-name:pl-s1;}
span.pl-kos
{mso-style-name:pl-kos;}
span.pl-en
{mso-style-name:pl-en;}
span.pl-pds
{mso-style-name:pl-pds;}
span.pl-c1
{mso-style-name:pl-c1;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>In the next example I wrote a whole setup:<o:p></o:p></p><p class=MsoNormal><a href="https://github.com/elico/vagrant-squid-outgoing-addresses">https://github.com/elico/vagrant-squid-outgoing-addresses</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Specifically it would look something like:<o:p></o:p></p><p class=MsoNormal><a href="https://github.com/elico/vagrant-squid-outgoing-addresses/blob/master/shared/note.rb#L82">https://github.com/elico/vagrant-squid-outgoing-addresses/blob/master/shared/note.rb#L82</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>it’s as a line like:<o:p></o:p></p><p class=MsoNormal>echo “OK x_note=100 ip=100”<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The in squid use an acl like this:<o:p></o:p></p><p class=MsoNormal><a href="https://github.com/elico/vagrant-squid-outgoing-addresses/blob/9221a73394ced582fec84bc42abfaae3c9a364b3/shared/collect-32-subnet-addresses.rb#L17">https://github.com/elico/vagrant-squid-outgoing-addresses/blob/9221a73394ced582fec84bc42abfaae3c9a364b3/shared/collect-32-subnet-addresses.rb#L17</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>ie:<o:p></o:p></p><p class=MsoNormal><span class=pl-s>echo "acl </span><span class=pl-kos>#{</span><span class=pl-s1>ip_map</span><span class=pl-kos>[</span><span class=pl-s1>key</span><span class=pl-kos>]}</span><span class=pl-s> note ip </span><span class=pl-kos>#{</span><span class=pl-s1>acl_name</span><span class=pl-kos>.</span><span class=pl-en>match</span><span class=pl-kos>(</span><span class=pl-pds>/([0-9]+)/</span><span class=pl-kos>)[</span><span class=pl-c1>1</span><span class=pl-kos>]}</span><span class=pl-s>" |tee -a /etc/squid/conf.d/acl-to-ip.conf<o:p></o:p></span></p><p class=MsoNormal><span class=pl-s><o:p> </o:p></span></p><p class=MsoNormal><span class=pl-s>It’s better to run the lab and see the content of the conf files to understand it.<o:p></o:p></span></p><p class=MsoNormal><span class=pl-s>You will need VirtualBox and Vagrant to power up this lab.<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Later I might be able to record a video of this but not sure yet about this.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Eliezer<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>----<o:p></o:p></p><p class=MsoNormal>Eliezer Croitoru<o:p></o:p></p><p class=MsoNormal>Tech Support<o:p></o:p></p><p class=MsoNormal>Mobile: +972-5-28704261<o:p></o:p></p><p class=MsoNormal>Email: <a href="mailto:ngtech1ltd@gmail.com">ngtech1ltd@gmail.com</a><o:p></o:p></p><p class=MsoNormal>Zoom: Coming soon<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> roee klinger <roeeklinger60@gmail.com> <br><b>Sent:</b> Sunday, January 10, 2021 5:51 PM<br><b>To:</b> squid-users@lists.squid-cache.org<br><b>Cc:</b> Eliezer Croitoru <ngtech1ltd@gmail.com><br><b>Subject:</b> Re: [squid-users] cache_peer selection based on username<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>So basically I return a note with the “OK” response, which can be any string, for example “100”.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Then, I can use “100” as a normal ACL in squid.conf?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal style='margin-bottom:12.0pt'>On Jan 10, 2021, at 17:36, Eliezer Croitoru <<a href="mailto:ngtech1ltd@gmail.com">ngtech1ltd@gmail.com</a>> wrote:<o:p></o:p></p></blockquote></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal><o:p></o:p></p><p class=MsoNormal>You should use a note acl for that.<o:p></o:p></p><p class=MsoNormal>When you return the whitelisted client you should add a note which can be 1-100 or any other static string.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>It works just out of the box.<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal>----<o:p></o:p></p><p class=MsoNormal>Eliezer Croitoru<o:p></o:p></p><p class=MsoNormal>Tech Support<o:p></o:p></p><p class=MsoNormal>Mobile: +972-5-28704261<o:p></o:p></p><p class=MsoNormal>Email: <a href="mailto:ngtech1ltd@gmail.com">ngtech1ltd@gmail.com</a><o:p></o:p></p><p class=MsoNormal>Zoom: Coming soon<o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal> <o:p></o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> squid-users <<a href="mailto:squid-users-bounces@lists.squid-cache.org">squid-users-bounces@lists.squid-cache.org</a>> <b>On Behalf Of </b>roee klinger<br><b>Sent:</b> Sunday, January 10, 2021 5:33 PM<br><b>To:</b> <a href="mailto:squid-users@lists.squid-cache.org">squid-users@lists.squid-cache.org</a><br><b>Subject:</b> [squid-users] cache_peer selection based on username<o:p></o:p></p></div><p class=MsoNormal> <o:p></o:p></p><div><p class=MsoNormal>Hey,<o:p></o:p></p><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>I am trying to figure out the best way to select cache peers based on the client username, I have read extensively but I cannot figure out the best way to do it.<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>so far I have:<o:p></o:p></p></div><blockquote style='margin-left:30.0pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><p class=MsoNormal><span style='font-size:7.5pt'>external_acl_type user_whitelist_external children-max=20 ttl=300 %>lp %>a script.sh</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>acl whitelisted_users external user_whitelist_external</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>http_access allow whitelisted_users</span><o:p></o:p></p></div></blockquote><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>and:<o:p></o:p></p></div><blockquote style='margin-left:30.0pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><p class=MsoNormal><span style='font-size:7.5pt'>nonhierarchical_direct off</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>never_direct allow all</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>cache_peer 192.168.8.1 parent 101 0 proxy-only default name=proxy1</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>cache_peer_access proxy1 allow whitelisted_users</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>cache_peer_access proxy0.2 deny all</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>cache_peer 192.168.8.2 parent 102 0 proxy-only default name=proxy2</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>cache_peer_access proxy2 allow whitelisted_users</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:7.5pt'>cache_peer_access proxy0.3 deny all</span><o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div></blockquote><p class=MsoNormal>ideally, script.sh checks if the request is authinticated and if it is, it selects the cache peer to use, is there some kind of way to achieve this with "<span style='font-size:9.0pt;font-family:Courier;color:#1E1E1E'>Defined keywords"</span><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#1E1E1E'> to select which cache peer to use or am I looking at this the wrong way?</span><o:p></o:p></p><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Arial",sans-serif;color:#1E1E1E'>What would be the best way to accomplish this?</span><o:p></o:p></p></div></div><p class=MsoNormal>_______________________________________________<br>squid-users mailing list<br><a href="mailto:squid-users@lists.squid-cache.org">squid-users@lists.squid-cache.org</a><br><a href="http://lists.squid-cache.org/listinfo/squid-users">http://lists.squid-cache.org/listinfo/squid-users</a><o:p></o:p></p></div></blockquote></div></body></html>