coder / code-server

VS Code in the browser
https://coder.com
MIT License
68.46k stars 5.61k forks source link

HTTP proxy environment variables support #124

Closed fancl20 closed 3 years ago

fancl20 commented 5 years ago

vscode use http_proxy and https_proxy environment variables if the proxy setting not set. It seems not to work when using code-server.

kylecarbs commented 5 years ago

We'd need to add proper VS Code networking setup to code-server. Not sure about this.

Ref: https://code.visualstudio.com/docs/setup/network

avindra commented 5 years ago

I'm also looking for proxy support (in order to install extensions).

As a workaround, I tried importing the vsix file directly, but this error shows up when I do that:

image

coadler commented 5 years ago

@avindra see https://github.com/codercom/code-server/issues/92

RichardMcSorley commented 5 years ago

Also looking forward to this support. Not able to run it on some networks due to this, makes code-server cumbersome to use.

fcomte commented 5 years ago

Does anybody success to install extension behind a proxy ? Iam using : version 1.604-vsc1.32.0

jrderuiter commented 5 years ago

Not yet, running into the same issue unfortunately.

kylecarbs commented 5 years ago

I'd be happy to implement this, but would concretely like to understand the importance. Does this just proxy all requests VS Code would normally make?

t-d-d commented 5 years ago

The only issue I have seen so far is that the installation of extensions doesn't respect the proxy setting, from the UI or via the --install-extension command line flag. Would graetly appreciate a fix for that.

jrderuiter commented 5 years ago

For me the main issue was also with installing extensions (I get a timeout because code-server doesn't go through the proxy). I also have some issues with icons (file icons, for example) in the browser, but that's probably not related.

fancl20 commented 5 years ago

The problem is that there exist many extensions to download binaries they need not during installing but during the first start up (like official C/C++ extension or Golang extensions). I'm not sure whether they regard the system proxy preference or using vscode setting.

t-d-d commented 5 years ago

@fancl20 are you aware of the vscode setting for this:

  // Use the proxy support for extensions.
  //  - off: Disable proxy support for extensions.
  //  - on: Enable proxy support for extensions.
  //  - override: Enable proxy support for extensions, override request options.
  "http.proxySupport": "override",

Maybe this https://github.com/cdr/code-server/pull/545 will help resolve this. Waiting on a new release to test it.

@jrderuiter regarding the icons, I just raised https://github.com/cdr/code-server/issues/627 . Agree, I don't think it is related.

t-d-d commented 5 years ago

@fancl20 I can confirm that the rest-client extension works fine behind a proxy with http_proxy set and the above vscode setting.

nhooyr commented 4 years ago

Related https://github.com/nodejs/node/issues/15620

nhooyr commented 4 years ago

Let's just use https://www.npmjs.com/package/proxy-from-env ?

benjaminbauer commented 4 years ago

I am also running code-server behind a proxy. What I find weird is, the extensions marketplace loads w/o any issues: image

but the installation fails: image

The error message does not reveal the cause. I even started code-server verbose with -vvv, but no errors/warnings or any hints regarding the installation failure of the extension

code-asher commented 4 years ago

Hmm, the extension list query runs from your browser while the download runs from code-server so that might explain the discrepancy. Were there any logs in VS Code's output panel? It would be under (Log) Remote Extension Host in the dropdown.

benjaminbauer commented 4 years ago

@code-asher : I do not get any related output, when the installation of the extension fails in Log (Remote Extension Host)

However I get:

in Log (Window):

[2020-04-07 11:04:06.029] [window] [trace] RequestService#request https://storage.googleapis.com/vscode-extension-assets/vscode-extensions/vscode/ms-python/python/2020.3.69010/Microsoft.VisualStudio.Code.Manifest
[2020-04-07 11:04:06.120] [window] [trace] RequestService#request https://storage.googleapis.com/vscode-extension-assets/vscode-extensions/vscode/ms-python/python/2020.3.69010/Microsoft.VisualStudio.Services.Content.Details
[2020-04-07 11:04:06.133] [window] [trace] RequestService#request https://storage.googleapis.com/vscode-extension-assets/vscode-extensions/vscode/ms-python/python/2020.3.69010/Microsoft.VisualStudio.Code.Manifest
[2020-04-07 11:04:06.141] [window] [error] getaddrinfo ENOTFOUND storage.googleapis.com: downloading: getaddrinfo ENOTFOUND storage.googleapis.com
    at /home/vagrant/.local/bin/code-server-3.0.2-linux-x86_64/lib/vscode/out/vs/server/entry.js:373:524
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

in Log (Remote Server)

[2020-04-07 09:06:11.212] [remoteagent] [info] Installing extension: ms-python.python
[2020-04-07 09:06:11.213] [remoteagent] [trace] Started scanning user extensions
[2020-04-07 09:06:11.214] [remoteagent] [trace] Scanned user extensions: 0
[2020-04-07 09:06:11.214] [remoteagent] [trace] Started downloading extension: ms-python.python
[2020-04-07 09:06:11.214] [remoteagent] [trace] ExtensionGalleryService#download ms-python.python
[2020-04-07 09:06:11.214] [remoteagent] [trace] RequestService#request https://storage.googleapis.com/vscode-extension-assets/vscode-extensions/vscode/ms-python/python/2020.3.69010/Microsoft.VisualStudio.Services.VSIXPackage?redirect=true&install=true
[2020-04-07 09:06:11.217] [remoteagent] [trace] RequestService#request https://storage.googleapis.com/vscode-extension-assets/vscode-extensions/vscode/ms-python/python/2020.3.69010/Microsoft.VisualStudio.Services.VSIXPackage?install=true
[2020-04-07 09:06:11.220] [remoteagent] [error] Failed to install extension: ms-python.python getaddrinfo ENOTFOUND storage.googleapis.com

Hint: The timestamps are different due to timezone foobar, the logs are take immediately after trying to install the plugin.

kylecarbs commented 4 years ago

Seems like you aren't able to resolve storage.googleapis.com. Is your DNS setup properly?

benjaminbauer commented 4 years ago

@kylecarbs no, thats not the case. curl storage.googleapis.com works just fine, since it respects http_proxy and https_proxy. When I unset the proxy variables in the ENV I also get curl: (6) Could not resolve host: storage.googleapis.com

kylecarbs commented 4 years ago

Sorry I misunderstood. code-server doesn't support the HTTP_PROXY and HTTPS_PROXY environment variables atm. That's why you're getting the issue mentioned.

Edit: Doesn't seem like it'd be that crazy to add, we'll take a look at it. Feel free to take a stab at it yourself, happy to provide guidance.

nhooyr commented 4 years ago

Part of the problem is definitely that we'd want to use the proxy client side as well but we can't really set it there.

edit: I was wrong, the browser should be configured to use the given proxies if required.

nhooyr commented 3 years ago

Will be in the next release! I think it's good to add a FAQ entry explaining how it works and how you need to also configure your browser.

nhooyr commented 3 years ago

Will be in the next release! 🎊 🍻