exclude local addresses in wpad

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have a proxy Ubuntu 18.04, with squid 3128 and apache2, and I publish the auto configuration file proxy.pac with the option dhcp 252.



The file has the following contents:



function FindProxyForURL(url, host) return "PROXY 192.168.0.10:3128";


There are applications on some computers within my local network that have these urls for access:



http://localhost:8080
http://192.168.0.12:8090/app/bar


The problem is squid has restrictions on this type of request



How can I configure the proxy.pac to exclude requests to local addresses? (example: 192.168.0.0/24 or localhost:port)



Important to note that a temporary solution is to manually put the ip:port of the proxy in the browsers (in Windows: Control Panel/Internet Options), and select the box "do not use proxy server for local addresses", but then the proxy.pac would not make sense.










share|improve this question



























    up vote
    1
    down vote

    favorite












    I have a proxy Ubuntu 18.04, with squid 3128 and apache2, and I publish the auto configuration file proxy.pac with the option dhcp 252.



    The file has the following contents:



    function FindProxyForURL(url, host) return "PROXY 192.168.0.10:3128";


    There are applications on some computers within my local network that have these urls for access:



    http://localhost:8080
    http://192.168.0.12:8090/app/bar


    The problem is squid has restrictions on this type of request



    How can I configure the proxy.pac to exclude requests to local addresses? (example: 192.168.0.0/24 or localhost:port)



    Important to note that a temporary solution is to manually put the ip:port of the proxy in the browsers (in Windows: Control Panel/Internet Options), and select the box "do not use proxy server for local addresses", but then the proxy.pac would not make sense.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a proxy Ubuntu 18.04, with squid 3128 and apache2, and I publish the auto configuration file proxy.pac with the option dhcp 252.



      The file has the following contents:



      function FindProxyForURL(url, host) return "PROXY 192.168.0.10:3128";


      There are applications on some computers within my local network that have these urls for access:



      http://localhost:8080
      http://192.168.0.12:8090/app/bar


      The problem is squid has restrictions on this type of request



      How can I configure the proxy.pac to exclude requests to local addresses? (example: 192.168.0.0/24 or localhost:port)



      Important to note that a temporary solution is to manually put the ip:port of the proxy in the browsers (in Windows: Control Panel/Internet Options), and select the box "do not use proxy server for local addresses", but then the proxy.pac would not make sense.










      share|improve this question















      I have a proxy Ubuntu 18.04, with squid 3128 and apache2, and I publish the auto configuration file proxy.pac with the option dhcp 252.



      The file has the following contents:



      function FindProxyForURL(url, host) return "PROXY 192.168.0.10:3128";


      There are applications on some computers within my local network that have these urls for access:



      http://localhost:8080
      http://192.168.0.12:8090/app/bar


      The problem is squid has restrictions on this type of request



      How can I configure the proxy.pac to exclude requests to local addresses? (example: 192.168.0.0/24 or localhost:port)



      Important to note that a temporary solution is to manually put the ip:port of the proxy in the browsers (in Windows: Control Panel/Internet Options), and select the box "do not use proxy server for local addresses", but then the proxy.pac would not make sense.







      dhcp squid http-proxy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 25 at 0:34









      Goro

      6,39552863




      6,39552863










      asked Sep 24 at 23:14









      user4839775

      9412




      9412




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Change the function to this:



          function FindProxyForURL(url,host) 
          var hostIP;
          if (isIpV4Addr.test (host))
          hostIP = host;

          else
          hostIP = dnsResolve(host);

          if (isInNet(hostIP, "192.168.0.0", "255.255.255.0"))
          return "DIRECT";

          if (host == "localhost")
          return "DIRECT";

          return "PROXY 192.168.0.10:3128";



          This first checks whether the host part is an IPv4 number. If so, that is directly used as the IP.



          If not, the host part is resolved to an IP address and the result is used.



          It then matches the IP address against the specified subnet; if that matches, the browser is instructed to directly access the host.



          If the hostname is "localhost", the browser is also instructed to directly access the host (although I wonder whether browsers will ever use this function for "localhost").



          Finally, the default is to use the proxy.






          share|improve this answer




















          • A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
            – user4839775
            Sep 25 at 13:28










          • This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
            – wurtel
            Sep 25 at 13:38










          • Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
            – user4839775
            Sep 25 at 20:09










          • New question unix.stackexchange.com/questions/471423/…
            – user4839775
            Sep 25 at 20:57










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471202%2fexclude-local-addresses-in-wpad%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          Change the function to this:



          function FindProxyForURL(url,host) 
          var hostIP;
          if (isIpV4Addr.test (host))
          hostIP = host;

          else
          hostIP = dnsResolve(host);

          if (isInNet(hostIP, "192.168.0.0", "255.255.255.0"))
          return "DIRECT";

          if (host == "localhost")
          return "DIRECT";

          return "PROXY 192.168.0.10:3128";



          This first checks whether the host part is an IPv4 number. If so, that is directly used as the IP.



          If not, the host part is resolved to an IP address and the result is used.



          It then matches the IP address against the specified subnet; if that matches, the browser is instructed to directly access the host.



          If the hostname is "localhost", the browser is also instructed to directly access the host (although I wonder whether browsers will ever use this function for "localhost").



          Finally, the default is to use the proxy.






          share|improve this answer




















          • A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
            – user4839775
            Sep 25 at 13:28










          • This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
            – wurtel
            Sep 25 at 13:38










          • Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
            – user4839775
            Sep 25 at 20:09










          • New question unix.stackexchange.com/questions/471423/…
            – user4839775
            Sep 25 at 20:57














          up vote
          1
          down vote



          accepted










          Change the function to this:



          function FindProxyForURL(url,host) 
          var hostIP;
          if (isIpV4Addr.test (host))
          hostIP = host;

          else
          hostIP = dnsResolve(host);

          if (isInNet(hostIP, "192.168.0.0", "255.255.255.0"))
          return "DIRECT";

          if (host == "localhost")
          return "DIRECT";

          return "PROXY 192.168.0.10:3128";



          This first checks whether the host part is an IPv4 number. If so, that is directly used as the IP.



          If not, the host part is resolved to an IP address and the result is used.



          It then matches the IP address against the specified subnet; if that matches, the browser is instructed to directly access the host.



          If the hostname is "localhost", the browser is also instructed to directly access the host (although I wonder whether browsers will ever use this function for "localhost").



          Finally, the default is to use the proxy.






          share|improve this answer




















          • A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
            – user4839775
            Sep 25 at 13:28










          • This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
            – wurtel
            Sep 25 at 13:38










          • Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
            – user4839775
            Sep 25 at 20:09










          • New question unix.stackexchange.com/questions/471423/…
            – user4839775
            Sep 25 at 20:57












          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Change the function to this:



          function FindProxyForURL(url,host) 
          var hostIP;
          if (isIpV4Addr.test (host))
          hostIP = host;

          else
          hostIP = dnsResolve(host);

          if (isInNet(hostIP, "192.168.0.0", "255.255.255.0"))
          return "DIRECT";

          if (host == "localhost")
          return "DIRECT";

          return "PROXY 192.168.0.10:3128";



          This first checks whether the host part is an IPv4 number. If so, that is directly used as the IP.



          If not, the host part is resolved to an IP address and the result is used.



          It then matches the IP address against the specified subnet; if that matches, the browser is instructed to directly access the host.



          If the hostname is "localhost", the browser is also instructed to directly access the host (although I wonder whether browsers will ever use this function for "localhost").



          Finally, the default is to use the proxy.






          share|improve this answer












          Change the function to this:



          function FindProxyForURL(url,host) 
          var hostIP;
          if (isIpV4Addr.test (host))
          hostIP = host;

          else
          hostIP = dnsResolve(host);

          if (isInNet(hostIP, "192.168.0.0", "255.255.255.0"))
          return "DIRECT";

          if (host == "localhost")
          return "DIRECT";

          return "PROXY 192.168.0.10:3128";



          This first checks whether the host part is an IPv4 number. If so, that is directly used as the IP.



          If not, the host part is resolved to an IP address and the result is used.



          It then matches the IP address against the specified subnet; if that matches, the browser is instructed to directly access the host.



          If the hostname is "localhost", the browser is also instructed to directly access the host (although I wonder whether browsers will ever use this function for "localhost").



          Finally, the default is to use the proxy.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 25 at 9:44









          wurtel

          9,46511324




          9,46511324











          • A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
            – user4839775
            Sep 25 at 13:28










          • This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
            – wurtel
            Sep 25 at 13:38










          • Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
            – user4839775
            Sep 25 at 20:09










          • New question unix.stackexchange.com/questions/471423/…
            – user4839775
            Sep 25 at 20:57
















          • A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
            – user4839775
            Sep 25 at 13:28










          • This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
            – wurtel
            Sep 25 at 13:38










          • Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
            – user4839775
            Sep 25 at 20:09










          • New question unix.stackexchange.com/questions/471423/…
            – user4839775
            Sep 25 at 20:57















          A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
          – user4839775
          Sep 25 at 13:28




          A masterpiece Thank you very much. Only a small detail. It works well in chrome, but not in firefox. Any suggestions?
          – user4839775
          Sep 25 at 13:28












          This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
          – wurtel
          Sep 25 at 13:38




          This should work in any browser, including Internet Explorer, Edge, and also firefox. Check your webserver logs to see if firefox is actually loading the wpad file.
          – wurtel
          Sep 25 at 13:38












          Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
          – user4839775
          Sep 25 at 20:09




          Your pac file answers my question (that's why I select it as correct), however it compromises navigation. I will ask the question again.
          – user4839775
          Sep 25 at 20:09












          New question unix.stackexchange.com/questions/471423/…
          – user4839775
          Sep 25 at 20:57




          New question unix.stackexchange.com/questions/471423/…
          – user4839775
          Sep 25 at 20:57

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471202%2fexclude-local-addresses-in-wpad%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos