nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.31k stars 3.88k forks source link

Adding an API to configure proxy [$85] #916

Closed clowwindy closed 9 years ago

clowwindy commented 11 years ago

In 0.6.3 an API to get proxy for url has been added. Can we have an API to set proxy?

Chrome has a proxy API, which doesn't affect system settings. I'm wondering if nw could have the same feature.

http://developer.chrome.com/extensions/proxy.html

Did you help close this issue? Go claim the $85 bounty on Bountysource.

xdqi commented 11 years ago

Well, I wonder it could develop a method to support PAC file.

wikipedia:http://en.wikipedia.org/wiki/Proxy_auto-config

wwqgtxx commented 11 years ago

like it too......

erikjjohnson commented 11 years ago

Right, can at least nw use the common HTTP_PROXY, http_proxy, HTTPS_PROXY, and https_proxy environment variables when it can't find any system settings?

The PAC and system support in this closed issue is wonderful:

https://github.com/rogerwang/node-webkit/issues/130?source=cc

But I've found some linux variants that don't supply the system proxy settings in a way Chrome or nw can understand. In those cases, either using the environment variables or a command line option to set the proxy would be helpful. Of course, the proxy given should be returned by the new API in the above issue

Pavel-Husakouski commented 10 years ago

Actually, it is quite annoying to work behind proxy using NW-application, because users are asked for the credentials twice - first for NW, second for Node

Pavel-Husakouski commented 10 years ago

I think there should be implemented some common way - i.e. environment variable HTTP_PROXY which is accessible from the NW and Node, or, another option, some API

liclac commented 10 years ago

Bump?

The project I'm working on at the moment needs me to find a portable web browser of some sort that runs things through a locally hosted proxy.
node-webkit would be perfect for the task if only I could figure out how to make it use said proxy…

Pavel-Husakouski commented 10 years ago

uppfinnarn: you can't unless the System config is set to your local hosted server. I implemented kind of http client to make nodewebkit working with my own proxy with authentication.

You can use chromium portable if you don't need any node.js modules. It has an extensions that allows you configure the proxy.

liclac commented 10 years ago

Looking at that now, thanks. Not as elegant as I could make my node-webkit solution (where I could run the proxy within the same process), but it works.

liclac commented 10 years ago

Nevermind, Windows only, back to looking for alternatives until (if) this gets addressed...

felicienfrancois commented 10 years ago

Need it too ...

mkoryak commented 10 years ago

+1

toddhay commented 10 years ago

+1 as well

felicienfrancois commented 10 years ago

An API method would be cool but supporting the --proxy-server chromium arg is a first step and is probably easy to implement.

epodolyak commented 10 years ago

+1

davidrapin commented 10 years ago

I support felicienfrancois proposal to support the --proxy-server arg. For users that cannot edit their system proxy configuration (at work for example), this is really necessary.

iampuma commented 10 years ago

+1 would be very useful

wells1013 commented 10 years ago

+1 like it too......

tholder commented 10 years ago

+1

AlexVBr commented 10 years ago

++

devon commented 10 years ago

+1

devon commented 10 years ago

This feature is quite important for Chinese :+1:

cchersin commented 10 years ago

+1

devon commented 9 years ago

proxy_service.cc:

#if defined(OS_WIN)
  return new ProxyConfigServiceWin();
#elif defined(OS_IOS)
  return new ProxyConfigServiceIOS();
#elif defined(OS_MACOSX)
  return new ProxyConfigServiceMac(io_thread_task_runner);

I think this is the code to check the system proxy. I will try to 'hard coding' the proxy setting before this issues be fixed.

jaredallard commented 9 years ago

+1 this is very important for anyone who needs to have their content go through any sort of proxy, i.e tor.

131 commented 9 years ago

I created a node module to manage the system proxy. Only working in windows (xp/7/+) for now on. https://github.com/131/proxytoggle

Pavel-Husakouski commented 9 years ago

Looks like your module requires .Net to be installed and don't support anything we need in this issue - proxy credentials and configuration

131 commented 9 years ago

Yep, leave that to node-proxy (so your nw app start & configure it's own proxy configuration), my toggle is just here to force nw to use it.

tommoor commented 9 years ago

cough - oh, I mean +1

clowwindy commented 9 years ago

Oh, atom-shell implemented this: https://github.com/atom/atom-shell/issues/584 Exactly what I need.

rogerwang commented 9 years ago

@clowwindy this is still an issue of node-webkit so I'm re-opening this.

rogerwang commented 9 years ago

@clowwindy And a command line option is not an API, which you proposed in OP.

rogerwang commented 9 years ago

documented here: https://github.com/rogerwang/node-webkit/wiki/App#setproxyconfigconfig

tommoor commented 9 years ago

Roger, can a username/password be passed with this?

Thanks for your work!

On Mon, Nov 17, 2014 at 11:59 PM, Roger Wang notifications@github.com wrote:

documented here: https://github.com/rogerwang/node-webkit/wiki/App#setproxyconfigconfig

Reply to this email directly or view it on GitHub: https://github.com/rogerwang/node-webkit/issues/916#issuecomment-63434134

rogerwang commented 9 years ago

@tommoor I'm afraid not, but later a username / password dialog will be shown to the user upon network request.

Pavel-Husakouski commented 9 years ago

Ok, how to set the proxy credentials and change them on fly ?

Pavel-Husakouski commented 9 years ago

Look, there are lots of cases - i.e. when app opens external page that makes ajax requests - credentials are required When the app uses node http to make some requests. Node http is required to bypass several restrictions of XHR. Credentias are required again

When the password expires or user switches to different network, he must re-enter the credentials . Such cases are impossible to implement

ayapi commented 9 years ago

@rogerwang Thank you for your work! Any plans to support PAC(Proxy Auto-Config)? auto_detect and pac_url are in net/proxy/proxy_config.cc but currently in node-webkit App#setProxyConfig() handles only proxy_rules. PAC is very useful. Please consider it.

rogerwang commented 9 years ago

@ayapi yeah, would like to support it. Re-open this issue for this.

alvinteh commented 9 years ago

I'd like to add that it seems App.setProxyConfig() does not seem to be working - network requests initiated by Chromium still go use the system proxy settings.

Tested with nw 0.11.2 on CentOS 7 (with GNOME desktop) and Squid proxy.

brospars commented 9 years ago

@tommoor Have you find any solution to autologin in proxy configuration ? My app is meant to run alone without any interaction so I must find a way to do that..

bestplay commented 9 years ago

After gui.App.setProxyConfig Devtools show Empty

With 12.0 & 12.2 for win7 32bit . And operating system is win7 64bit.

After set proxy by setProxyConfig. and proxy works good. But Devtools show Empty.

My proxy string pass to setProxyConfig is : "http=192.168.2.2:8087;https=192.168.2.2:8087;socks=direct://" OR "http=192.168.2.2:8087;direct://"

Both cause the same result.

Remote debugging via local socket? And how can I passby the local socket for remote debugging?

aluxian commented 9 years ago

+1 I have the same problem as @bestplay :(

Zensin commented 9 years ago

This can be done by CLI argument in Electron (Previously named Atom Shell) via a commit that was made a while ago right? Should it not now be easy to add to nw.js?

rogerwang commented 9 years ago

@ayapi the support for auto detect proxy and PAC url will be added in the next 0.12.4 release. Thanks for your patience.

ayapi commented 9 years ago

Thank you very much!

bitnom commented 8 years ago

I know a lot of people would love to use nwjs for web automation and so being able to rotate proxies with logins and no user interaction required is essential. There are other use-cases as well.

jakubnavratil commented 8 years ago

Please merge commit by rogerwang c45f686