Windows 10 WSL Ubuntu 18.04 proxy configuration for apt.
David J Eddy

David J Eddy @david_j_eddy

About: AWS Certified (x4), Automated Testing / Continuous Integration / Delivery / Deployment (CI/CDs), Cloud, Containers, Dev(Sec)Ops, Software Engineer.

Location:
Internet
Joined:
Sep 8, 2017

Windows 10 WSL Ubuntu 18.04 proxy configuration for apt.

Publish Date: Nov 15 '18
20 12

Using Windows Subsystem for Linux (WSL) can be a great tool for dev's, op's, and admin's alike. The downside often these roles are after larger organization that gave Firewalls and tight proxy security.

I found myself in this exact situation. The corp. proxy uses a *.pac file script. Nothing in the Debian world does. Ugg. Here is how I got Debian apt to work behind a proxy.

Original Solution Source from the Linux Questions Forums.

wget http://some.domain.tld/some-proxy.pac

...or you can probably just open it with a browser.

Look for the proxy address that is used if all other options fail. Typically towards the bottom / in a function call of its own.

    function FindProxyForURL(url, host) { return "PROXY proxy.foo.com:8080; DIRECT"; }

Take note of the URL:PORT address.

Finally, put this in your /etc/apt/apt.conf file:

    Acquire::http::Proxy "http://proxy.foo.com:8080";

Log out and back in. At this point apt-get update -y and related apt commands should work as expected.

Comments 12 total

  • Mr Daily
    Mr DailyNov 15, 2018

    good

  • Felicitas Pojtinger
    Felicitas PojtingerNov 16, 2018

    Use GNU/Linux

    • David J Eddy
      David J EddyNov 16, 2018

      Sadly in the business world 95%+ of computing machines will run Windows; VMs are a valid option but with bare bones hardware it would be un-usable. WSL is a nice middle ground.

      • Felicitas Pojtinger
        Felicitas PojtingerNov 16, 2018

        It's proprietary, non-free and just ... objectivly speaking bad (unlike macOS, for example). Also, I would argue that the PC is rapidly becoming a niche product (at least for my generation) and since all smartphones run either FreeBSD/Darwin (iOS) or Linux (Android) with a PWA compatible browser, the primary platform to develop for definitely isn't Windows, but the web, and as for servers it's GNU/Linux for sure since a long time now, and LDK (Linux - Docker - Kubernetes) is the future for sure. In addition to that, doing anything else than primitive bash scripting isn't possible in WSL (which doesn't have anything to do with Linux, but GNU - thus the correct name should be GNU/NT) and thus the system is obsolete. Especially since using GNU/Linux/FreeBSD/Darwin is so easy now there really is no reason to use that legacy proprietary blob that literally preinstalls Candy Crush in 2018.

        • David J Eddy
          David J EddyNov 16, 2018

          I do not disagree with you. :)

          • Felicitas Pojtinger
            Felicitas PojtingerNov 16, 2018

            Oh, I'm sorry if I was sounding to harsh, I forgot to put a </rant> there ;)

            • Vinicius Seixas
              Vinicius SeixasOct 22, 2019

              I agree with your rant but WSL is not as useless as you say. I work at a place where I have no option but use Win so I use WSL for multiple purposes and it works perfectly well for most of it. For instance, I'm just installing an ActiveMQ server in WSL. And I also use VS Code Remote with WSL wich is awesome.

              • Sharthak Ghosh
                Sharthak GhoshDec 12, 2019

                VS Code Remote changes everything. So many things possible now

  • Emprint
    EmprintJul 18, 2019

    Thanks!

  • Mincheol Kim
    Mincheol KimAug 21, 2019

    Now, WSL2 is awesome!

  • Ryan Paderna
    Ryan PadernaMar 24, 2021

    Hi. The etc/apt/apt.conf file is no longer there in the current version of WSL. Only apt.conf.d folder. No apt.conf file inside the apt.conf.d folder.

    • Josh Carpenter
      Josh CarpenterJun 3, 2021

      You can just create the file and add the line. Working for me now in 20.04

Add comment