sjitech / proxy-login-automator

A single node.js script to automatically inject user/password to http proxy server via a local forwarder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't we use a local pac?

huangjinshe opened this issue · comments

commented

The tools idea is great, why we need to use this just because use it with PAC, if we need to set proxy with username and password, we could do it in any device, PC(windows), phone(such like iphone), but use this way, we could use it with PAC + (proxy-login-automator, because basic PAC lookes like does not support use username and password), But I don't know how to do that now.

For to do that I need to use PAC of course, But the problem is I need put the pac to local , then I put the local address to my phone, like: http://192.168.1.X/mypac.pac, when I access google I need to go with proxy server such like: (write it in mypac.pac)

function FindProxyForURL(url, host) {
    if (shExpMatch(url,"*.google.com*")) { 
        return"PROXY remote-server:remote-port";
    }
    return"DIRECT";
}

Any other address, I don't need to use proxy.

But, How to do that? the home page only told us use remote pac, why we need to use remote pac? we just need to decide use local network or proxy, for that we should go to the remote every time??

Please tell me some idea, or maybe I'm not understand good enough.

commented

I just worry If we still use the remote PAC, the every request will go throw to the remote, if we just want some URL go to remote proxy server, but in this case, there is no point if every request still use remote network.

commented

In another case, if the remote server only for a proxy feature, then there is no any point to access : http://Remote:Port/pac.file, Because the remote server is just a proxy server, not a web server, how do we put the pac file to a non web server? I think local pac idea is more important, and the current design I still can't understand.

commented

I recalled that I have ever done the local PAC server as you expected. This is what i did:

  1. prepare a PAC file e.g. mypac.pac
function FindProxyForURL(url, host) {
    if (shExpMatch(url,"*.google.com*")) { 
        return"PROXY remote-server:remote-port";
    }
    return"DIRECT";
}
  1. install http-server utility
npm install -g http-server
  1. run http-server on current dir, serve port 18080
http-server -p 18080

Then you got a local PAC server http://localhost:18080, the PAC itself can be accessed from http://localhost:18080/mypac.pac

Then you run proxy-login-automator:

node proxy-login-automator.js \
 -local_port 65000 \
 -remote_host localhost \
 -remote_port 18080 \
 -usr USR -pwd PWD \
 -as_pac_server true         ##### this is important #####

Then you configure your browser's PAC URL with

--proxy-pac-url=http://localhost:65000/mypac.pac

For Chrome on MacOS:

“/Applications/Google Chrome.app/Contents/MacOS/Google Chrome” \
   --user-data-dir=$HOME/chrome_data/ \
   --proxy-pac-url=http://localhost:65000/mypac.pac \
   >/dev/null 2>&1 &

For Chrome on Windows:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" \
  --user-data-dir=%APPDATA%\chrome_data \
  --proxy-pac-url=http://localhost:65000/mypac.pac
commented

@jjqq2013 , Thanks for you solution, but maybe your not understand what I mean. or I'm not understand. In this case if you need to use http-server, I could access it from LAN from my phone, then I still need to use the proxy-login-automator? I hope if we could just let proxy-login-automator do the PAC part, then when we access it, the Phone always get the data from LAN network(local city, or country) or the remote server network(from other city or country).

commented

The purpose of this tool is just inject user/password automatically.
If you just want to use a local PAC file without such a user/password injection, then you can just use http-server to serve the PAC file and need not to use proxy-login-automator.