Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't we use a local pac? #14

Closed
huangjinshe opened this issue Feb 24, 2018 · 5 comments
Closed

Can't we use a local pac? #14

huangjinshe opened this issue Feb 24, 2018 · 5 comments

Comments

@huangjinshe
Copy link

huangjinshe commented Feb 24, 2018

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:https://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.

@huangjinshe
Copy link
Author

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.

@huangjinshe
Copy link
Author

In another case, if the remote server only for a proxy feature, then there is no any point to access : http:https://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.

@jjqq2013
Copy link
Contributor

jjqq2013 commented Apr 10, 2018

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:https://localhost:18080, the PAC itself can be accessed from http:https://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:https://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:https://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:https://localhost:65000/mypac.pac

@huangjinshe
Copy link
Author

@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).

@jjqq2013
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants