WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Running behind corporate proxy

Open ghost opened this issue 9 years ago • 31 comments

Hi,

It would appear IE's proxy settings are not made available to the BASH shell, is this by design?

This causes the APT process post the initial extraction of the subsystem to hang and thus the apt process must be killed to allow you to configure the username etc.

So what does this mean for the environment if anything?

As it is not in place there is no way to populate the apt.conf file with proxy information and the file does not exist even post configuring the user etc.

FYI : adding the configuration post user configuration an populating the proxy information apt work as desired, but the original issue obviously is still present.

Win 10.0.14393

Barry

ghost avatar Jan 05 '17 10:01 ghost

@barryb20 - Thanks for your post and feedback. For future posts, please use the format in contributing.md.

Regarding this post, what browser proxy settings are you looking to extend to the bash shell, during installation?

sunilmut avatar Jan 07 '17 00:01 sunilmut

Yes, facing the same problem and unable to set the proxy on the shell and henceforth unable to use apt commands. Also apt.conf file is missing. It would be great if we could extend the system proxy or from a browser (ex: Chrome, Firefox or IE) to the bash shell.

ag2307 avatar Jan 07 '17 09:01 ag2307

@sunilmut The proxy configuration for the APT process to access the Ubuntu servers during initial setup. The linuxsubsystem is downloaded from the Store, extracted then hangs as the APT process is attempting to do something in the background.

@agrocks23 I did the steps below once I was in the BASH shell, Ihad to end task on APT post the initial file extraction pre the user configuration. gksudo gedit /etc/apt/apt.conf Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

ghost avatar Jan 07 '17 10:01 ghost

@barryb20 But the problem is on my build, Windows bash doesn't have gedit , gksudo etc. resources pre-installed. Plus apt.conf file is missing from /etc/apt , so where to do my proxy settings. Microsoft Windows [Version 10.0.14393]

capture

ag2307 avatar Jan 07 '17 11:01 ag2307

@agrocks23 yeah it confused me too mate, you need to create it as a new file,

Try sudo nano apt.conf or if your really brave sudo vi apt.conf (it was so long since I used vi I had to Google the quit cmd lol I had it right but the wrong way round)

If no authentication required:

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

Authentication required:

http_proxy=http://username:password@yourproxyaddress:proxyport

then save the file one you put your proxy settings in it.

Be warned however if your proxy needs authentication you will need to place your username and the password for said authentication in the apt.conf file and it is plain text.

Barry

ghost avatar Jan 07 '17 11:01 ghost

what's work for me : Created a proxy.conf file in /etc/apt/apt.conf.d/ Inside this file i put : Acquire::http::Proxy "http://myproxy:myproxyport";

eliohann avatar Jan 10 '17 09:01 eliohann

@eliohann thanks, but unfortunately that doesn't resolve my initial configuration hang issue prior to the configuration of the username and password.

ghost avatar Jan 10 '17 10:01 ghost

Thanks @barryb20. I have opened a bug on this.

sunilmut avatar Jan 13 '17 00:01 sunilmut

I had this issue too, and it was worse than just not being able to run behind the proxy, but that I couldn't even install the distribution at all. I only happened to try this again while at home and found that it did work at that time. I wouldn't have been able to follow the suggestion on changing the apt.conf settings as @barryb20 did, because there wasn't any Bash on Ubuntu on Windows to even do that with.

klauern avatar Jan 20 '17 13:01 klauern

@klauern Yeah I created a document for our Devs to let them know there is no issue on a none corporate (dirty) Internet connection, and to end the APT task when in the office.

It could be that your office proxy is blocking the Microsoft Store / Updates where it is pulling the shell down from. Check if either are blocked.

ghost avatar Jan 20 '17 13:01 ghost

Hi everyone, Please help answer a couple questions to help us resolve this issue:

  1. In WSL, is it only APT that has trouble accessing the internet? Do the following commands work? wget www.microsoft.com curl www.microsoft.com
  2. In Windows, if you have only set the IE proxy and not the systemwide proxy (winhttp), have you encountered Windows programs that do not respect the IE proxy settings and are thus unable to access the internet?

Thanks!

JasonLinMS avatar Jan 25 '17 23:01 JasonLinMS

Hello @JasonLinMS

1. do wget and curl work

Just a couple tests on my end, but I unset my /etc/environment settings and tried curl and wget. It appears that without that set, my bash won't work for anything. For me, I have to have both the APT settings configured in apt.conf for apt / apt-get to work, as well as an /etc/environment/ for everything else:

wget timeouts

2017-01-25 18_32_51-program manager

curl timeouts

2017-01-25 18_35_39-cmder

2. Do other apps respect the IE proxy settings

Generally speaking, they do. The exception I've encountered is apps that were cross-compiled from Linux, but over time, I've seen that less and less as toolsets seem to add that hook or functionality in later versions. That said, I tend to spend a lot of my time looking for proxy configs when I see things not working immediately.

For my case, the biggest issue is just not being able to run the installer at all to get started without having to be outside of a proxy. I could probably get some kind of exception rule added with our security group's help, but I would need to know what to request ahead of time. From that point forward, however, I still have to own up to the fact that most/all of our Linux systems require a proxy configuration, and would require extra configuration (which could be handled by some kind of script and/or after-installation cookbook).

klauern avatar Jan 26 '17 00:01 klauern

@klauern Thanks, for the failure to run the installer, do you know if the installer tarball is failing to download? Or if the tarball is downloaded and extracted, but the next step (running apt) fails to run. It should be easy to tell based on the messages in bash.exe during installation.

JasonLinMS avatar Jan 26 '17 01:01 JasonLinMS

@JasonLinMS -

Thanks, for the failure to run the installer, do you know if the installer tarball is failing to download? Or if the tarball is downloaded and extracted, but the next step (running apt) fails to run.

Look at @barryb20 response above @sunilmut The proxy configuration for the APT process to access the Ubuntu servers during initial setup. The linuxsubsystem is downloaded from the Store, extracted then hangs as the APT process is attempting to do something in the background.

sunilmut avatar Jan 26 '17 01:01 sunilmut

@JasonLinMS - I don't believe the installer tarball is failing to download, but what I see is the following:

C:\Users\username>lxrun /install
-- Beta feature --
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms

Type "y" to continue: y
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutes...

I think it's more that APT attempts to do some post-install configuration before you can get anywhere, and that is hanging up.

klauern avatar Jan 26 '17 13:01 klauern

Thanks everyone for the comments.

  1. For the case where the proxy settings need to be set inside WSL after installation, we consider that expected behavior since native Ubuntu requires that as well.
  2. For the case where the WSL installation fails, @benhillis introduced the following mitigation measures in Insider build 14986 (will also be available in Creators Update)
    1. When your system locale is English, APT will not be run during WSL installation. This means that during installation, the only step using the network is the download of the WSL tarball and desktop shortcut icon from Azure.
    2. When your system locale is non-English, APT will be run during WSL installation to download additional Ubuntu language packs if you say yes at the prompt. A timeout of a few minutes has been added to stop running APT if the command hangs, such as due to no network access. The installation can then continue with prompting for user name and password after the timeout.

Let us know if there are any further issues with installation in Insider build 14986+.

JasonLinMS avatar Jan 27 '17 20:01 JasonLinMS

Thanks @JasonLinMS we will download and test.

ghost avatar Jan 31 '17 09:01 ghost

Setting proxy environment variables in /etc/environment doesn't work for me. They do not get picked up from what I see when running printenv. Is it neccessary to somehow restart the ubuntu instance? Or re-login? And if yes, how?

luchsamapparat avatar Feb 09 '17 14:02 luchsamapparat

@luchsamapparat -- regarding getting a login shell, see #816

aseering avatar Feb 09 '17 14:02 aseering

Thanks, that works when using ~/.profile

luchsamapparat avatar Feb 09 '17 15:02 luchsamapparat