{"id":179,"date":"2018-06-13T17:08:20","date_gmt":"2018-06-13T20:08:20","guid":{"rendered":"http:\/\/xaxowareti.com.br\/?p=179"},"modified":"2018-06-13T17:08:20","modified_gmt":"2018-06-13T20:08:20","slug":"setting-up-wpad-autoconfigure-for-the-squid-package","status":"publish","type":"post","link":"https:\/\/xaxowareti.com.br\/?p=179","title":{"rendered":"Setting up WPAD Autoconfigure for the Squid Package."},"content":{"rendered":"<h1>Setting up WPAD Autoconfigure for the Squid Package<\/h1>\n<p>pfSense can be configured to serve up automatic proxy configuration data to clients to point users to squid running either on pfSense or another local system, assuming their systems settings are configured for this behavior. Though the data can be served from the firewall, the task is better suited for another local web server if one is available.<\/p>\n<div class=\"admonition note\">\n<p class=\"first admonition-title\">Note<\/p>\n<p class=\"last\">To use the web server on the firewall to serve this data, the GUI must run in HTTP mode, or the vhosts package may be used to setup an alternate HTTP server on port 80. Neither of these are recommended as much as running a separate local web server for this task.<\/p>\n<\/div>\n<p>This process is known as WPAD, short for\u00a0<a class=\"reference external\" href=\"http:\/\/en.wikipedia.org\/wiki\/Web_Proxy_Autodiscovery_Protocol\">Web Proxy AutoDiscovery Protocol<\/a>. If a web browser is configured for autodiscovery, it will try a few methods to figure out a proxy\u2019s location.<\/p>\n<p>A WPAD host may be supplied via DHCP numbered option 252 (string value containing the entire URL to the WPAD file) or DNS, which is easy to do with the built-in DNS forwarder.<\/p>\n<div id=\"why-would-this-be-done\" class=\"section\">\n<h2>Why would this be done?<\/h2>\n<p>To use squid authentication, squid cannot be used in transparent mode. HTTPS traffic also cannot be filtered using transparent mode. When squid is run in normal mode, a proxy IP and port must be configured on each client machine, which can be tedious. This can also cause problems on road warrior laptops that come in and out of the network. Rather than resetting their proxy configuration each time they enter and leave, autoconfigure will let them come and go without much trouble.<\/p>\n<p>Most, if not all, modern browsers ship with the autoconfigure setting turned off, so it may still be necessary to push\/enter this setting to client PCs. Even so, another advantage of using autoconfigure is that should squid move to another IP address, only one file must be changed to inform the clients of the updated IP address. (This may be easy to pull off in a windows domain with AD, but not for many others!)<\/p>\n<\/div>\n<div id=\"prerequisites\" class=\"section\">\n<h2>Prerequisites<\/h2>\n<p>This How-To assumes squid is already operating in a non-transparent configuration. For help with that, look elsewhere in this documentation and on the Forums.<\/p>\n<\/div>\n<div id=\"create-wpad-dat\" class=\"section\">\n<h2>Create wpad.dat<\/h2>\n<p>Before starting, a\u00a0<em>wpad.dat<\/em>\u00a0file must be crafted. This is a single file with a JavaScript function which tells the browser how to find a proxy hostname and port. This function can be as simple or as complex as desired, there are many examples on the web. In this example, all clients will be directed to the squid instance on the firewall.<\/p>\n<p>The contents of the example\u00a0<em>wpad.dat<\/em>\u00a0file are:<\/p>\n<div class=\"highlight-default notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"n\">function<\/span> <span class=\"n\">FindProxyForURL<\/span><span class=\"p\">(<\/span><span class=\"n\">url<\/span><span class=\"p\">,<\/span><span class=\"n\">host<\/span><span class=\"p\">)<\/span>\r\n<span class=\"p\">{<\/span>\r\n<span class=\"k\">return<\/span> <span class=\"s2\">\"PROXY 192.168.1.1:3128\"<\/span><span class=\"p\">;<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>The function in that file tells the browser to look for a proxy on\u00a0<em>192.168.1.1<\/em>\u00a0at port\u00a0<em>3128<\/em>.<\/p>\n<p>Now upload that file to pfSense or another locally accessible web server with scp, or create it using the built-in file editor. The file must go in\u00a0<em>\/usr\/local\/www\/<\/em>.<\/p>\n<p>Due to the different ways that various browser versions try to access the file, this same code should exist in at least three different places:<\/p>\n<div class=\"highlight-default notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"o\">\/<\/span><span class=\"n\">usr<\/span><span class=\"o\">\/<\/span><span class=\"n\">local<\/span><span class=\"o\">\/<\/span><span class=\"n\">www<\/span><span class=\"o\">\/<\/span><span class=\"n\">wpad<\/span><span class=\"o\">.<\/span><span class=\"n\">dat<\/span>\r\n<span class=\"o\">\/<\/span><span class=\"n\">usr<\/span><span class=\"o\">\/<\/span><span class=\"n\">local<\/span><span class=\"o\">\/<\/span><span class=\"n\">www<\/span><span class=\"o\">\/<\/span><span class=\"n\">wpad<\/span><span class=\"o\">.<\/span><span class=\"n\">da<\/span>\r\n<span class=\"o\">\/<\/span><span class=\"n\">usr<\/span><span class=\"o\">\/<\/span><span class=\"n\">local<\/span><span class=\"o\">\/<\/span><span class=\"n\">www<\/span><span class=\"o\">\/<\/span><span class=\"n\">proxy<\/span><span class=\"o\">.<\/span><span class=\"n\">pac<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>(More advanced users might do this from the shell and use\u00a0<em>ln<\/em>\u00a0to link the files.)<\/p>\n<p>We recommend pointing\u00a0<em>wpad.<\/em>\u00a0to an internal web server which can answer requests for the\u00a0<em>wpad.dat<\/em>\u00a0and associated files. It can be any web server, but typically must be served from both the default\u00a0<em>VirtualHost<\/em>\u00a0as well as one named\u00a0<em>wpad<\/em>, due to differences in how browsers request the file.<\/p>\n<p>To make this work using pfSense to serve the file, local IP addresses will need to be able to access the local interface IP address of the pfSense router. They do not need to access the WebGUI with a password, this file will be served without authentication. The GUI must also be run in HTTP mode, which is less secure. If the GUI is set to use HTTP, never open up access to the GUI over the WAN.<\/p>\n<\/div>\n<div id=\"configure-dns\" class=\"section\">\n<h2>Configure DNS<\/h2>\n<p>Now to setup the DNS portion. WPAD will take the domain name given to the machine, likely assigned by DHCP, and prepend\u00a0<em>wpad.<\/em>. If the domain is\u00a0<em>example.com<\/em>, it will look for\u00a0<em>wpad.example.com<\/em>. This task may be accomplished with the DNS Forwarder\/DNS Resolver in pfSense or with another internal DNS server used by client PCs.<\/p>\n<p>A client browser will ultimately try to access\u00a0<em>http:\/\/wpad.example.com\/wpad.dat<\/em>\u00a0&#8211; among others. More details on the hostnames tried by WPAD are available in the\u00a0<a class=\"reference external\" href=\"http:\/\/en.wikipedia.org\/wiki\/Wpad\">WPAD article on Wikipedia<\/a>.<\/p>\n<p>To add the entry using the DNS forwarder on pfSense, navigate to\u00a0<strong>Services &gt; DNS Forwarder<\/strong>. Click\u00a0<img decoding=\"async\" src=\"https:\/\/www.netgate.com\/docs\/pfsense\/_images\/fa-plus.png\" alt=\"fa-plus\" \/>\u00a0to add a new\u00a0<strong>Host Override<\/strong>.<\/p>\n<p>Enter the following (Replace the domain and IP address with their actual values):<\/p>\n<ul class=\"simple\">\n<li><strong>Host<\/strong>:\u00a0<em>wpad<\/em><\/li>\n<li><strong>Domain<\/strong>:\u00a0<em>example.com<\/em><\/li>\n<li><strong>IP Address<\/strong>:\u00a0<em>192.168.1.1<\/em><\/li>\n<li><strong>Description<\/strong>:\u00a0<em>WPAD Autoconfigure Host<\/em><\/li>\n<\/ul>\n<p>Click\u00a0<strong>Save<\/strong>.<\/p>\n<\/div>\n<div id=\"block-port-80-out-from-lan\" class=\"section\">\n<h2>Block Port 80 Out from LAN<\/h2>\n<p>Create a firewall rule at the TOP of the LAN tab (or appropriate interface) that blocks anything from\u00a0<strong>&lt;internal subnet&gt;<\/strong>\u00a0to * on port 80.<\/p>\n<div class=\"admonition note\">\n<p class=\"first admonition-title\">Note<\/p>\n<p class=\"last\">If the firewall is used to serve WPAD and the WebGUI anti-lockout rule has been disabled, web traffic must also be allowed to the pfSense firewall GUI port. If this is not acceptable, point\u00a0<em>wpad.<\/em>\u00a0to another internal web server which can answer requests for the\u00a0<em>wpad.dat<\/em>\u00a0and associated files.<\/p>\n<\/div>\n<\/div>\n<div id=\"test-clients\" class=\"section\">\n<h2>Test Clients<\/h2>\n<p>Fire up a browser on a client behind the pfSense firewall, and see what happens. If squid is configured for authentication, the client will be greeted with a login prompt. Otherwise, check squid\u2019s logs to ensure traffic is going through the proxy. A proxy test site such as<a class=\"reference external\" href=\"http:\/\/www.lagado.com\/proxy-test\">http:\/\/www.lagado.com\/proxy-test<\/a>\u00a0can also be useful.<\/p>\n<p>If nothing happened, check the browser settings. Many modern browsers ship with the autoconfigure settings off.<\/p>\n<div id=\"internet-explorer\" class=\"section\">\n<h3>Internet Explorer<\/h3>\n<ul class=\"simple\">\n<li>Open\u00a0<strong>Internet Options<\/strong><\/li>\n<li>Click the\u00a0<strong>Connections<\/strong>\u00a0tab<\/li>\n<li>Click the\u00a0<strong>LAN Settings<\/strong>\u00a0button<\/li>\n<li>Check\u00a0<strong>Automatically Detect Settings<\/strong><\/li>\n<li>Click\u00a0<strong>OK<\/strong>, and\u00a0<strong>OK<\/strong>\u00a0again.<\/li>\n<\/ul>\n<\/div>\n<div id=\"firefox\" class=\"section\">\n<h3>Firefox<\/h3>\n<ul class=\"simple\">\n<li>Click\u00a0<strong>Tools<\/strong>\u00a0(Or the three bar icon)<\/li>\n<li>Click\u00a0<strong>Options<\/strong><\/li>\n<li>Click\u00a0<strong>Advanced<\/strong><\/li>\n<li>Click the\u00a0<strong>Network<\/strong>\u00a0tab<\/li>\n<li>Click the\u00a0<strong>Settings<\/strong>\u00a0button<\/li>\n<li>Select\u00a0<strong>Auto-detect proxy settings for this network<\/strong><\/li>\n<li>Click\u00a0<strong>OK<\/strong><\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Setting up WPAD Autoconfigure for the Squid Package pfSense can be configured to serve up automatic proxy configuration data to clients to point users to squid running either on pfSense or another local system, assuming their systems settings are configured for this behavior. Though the data can be served from the firewall, the task is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-179","post","type-post","status-publish","format-standard","hentry","category-dicassolucoes"],"_links":{"self":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=179"}],"version-history":[{"count":1,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=\/wp\/v2\/posts\/179\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xaxowareti.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}