How to configure Atom to use proxy file (pac) settings? How to configure Atom to use proxy file (pac) settings? windows windows

How to configure Atom to use proxy file (pac) settings?


A .pac file is just a javascript file that browsers can run to programmatically determine which proxy to use. This is useful if your network needs to use different proxies to access different resources. If you open up that file, you'll probably be able to make sense of it (it's just javascript, after all) and figure out which proxy your network is using for general access to the web. Set that as your proxy in your .apmrc file and it should work.

Things get more complicated if your proxy requires some kind of authentication. If that's your problem, let me know. I have some experience dealing with it.


Authenticating

OK, so you need to authenticate. Then your situation is probably pretty similar to mine. You are correct in using CNTLM, we just need to configure it properly. Your cntlm.ini file will look something like this:

Username    <your windows username>Domain      <your domain name>Password    <leave this blank>PassLM      <get this by running `cntlm -H` on the command line>PassNT      <get this by running `cntlm -H` on the command line>PassNTLMv2  <get this by running `cntlm -H` on the command line>Proxy       <Your proxy address like ip_address:port>Proxy       <If you have multiple proxies, you may list them each on a new line>NoProxy     localhost, 127.0.0.*, <any others that should bypass the proxy>Listen      <a local port to listen on (I use 53128)>

There's something a bit funny that you should know about this file (cntlm.ini). When you install cntlm, it's included in the program's folder but it actually will only work if it's located at C:\Program Files (x86)\cntlm\cntlm.ini. I guess it's probably more accurate to say that it should be in the cntlm folder inside the PROGRAMFILES directory so you should double check that this is the case.

Anyway, having done all that, you can now start cntlm (instructions in the readme). Next, you need to configure apm to actually use your local proxy. Your .apmrc should look like this:

http-proxy = http://localhost:<port # from cntlm.ini>https-proxy = https://localhost:<port # from cntlm.ini>strict-ssl = false

You'd think this would be enough but there's more that might help. I had a lot of problems with npm until I found that https doesn't work well through cntlm so I needed to change my registry from https://registry.npmjs.org/ to http://registry.npmjs.org/. Since apm also uses the same registry, I decided to change that too:

apm config set registry http://registry.npmjs.org/

And then... it seemed to also help to go into Atom's config.cson and set core.proxy to http://localhost:<port # from cntlm.ini>

And after all that, I'd expect things to work for you. If it's cool and fine and Atom is working well, there's one more thing that you might want to do that will make most (all?) other apps (npm, git, etc) work well. On the command line, run:

netsh winhttp set proxy localhost:<port # from cntlm.ini> "localhost, 127.0.0.*"

This will save you the trouble of configuring most (all?) other apps one-by-one. For some reason, apm does need to be configured specifically. I guess it doesn't use the winhttp settings for some reason? I don't know the answer to that.

New Info 2016/03/18

I recently noticed that there's one additional thing you might need to do for some apps. You should set the following environment variables to your local proxy as well:

HTTP_PROXYHTTPS_PROXYFTP_PROXYhttp_proxyhttps_proxyftp_proxy

It may seem like overkill to set both upper and lower case but I recently installed MSys2 and found that it looks for the lower case versions so just set them all and save yourself some trouble.


You should download the file http://internal-server-name/sub-dir/file-name.pac and open it with a text editor, then find the actual proxy address and port inside it (near a PROXY keyword).


I used this for my trouble with npm and .npmrc

c:\users\%user%\.atom\.apmrc (add if not exist) and put this

proxy=http://YOUR-DOMAIN**%5C**USER-NAME:PASSWORD@YOUR-PROXY-SERVER:PORT/