Skip to main content
Solved

Curl Auto Proxy configuration Pac file


Forum|alt.badge.img+11

Hello All,

I am working on a script to curl something but we are using a .pac file,is this possible? If so anyone know how to?

Best answer by dwandro92

Just to clarify, you can permanently set your proxy URL for use with terminal commands, but it won't work with PAC files. Refer to How to set proxy environment variable in Unix/Linux if you aren't already aware of how to do this.

View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+3
  • New Contributor
  • 22 replies
  • December 3, 2015

As far as I know, no, curl doesn't support using javascript. I'm assuming that this script will be run from various networks and you won't know which proxy to use, hence the reliance upon the .pac file? You are able to supply curl with a proxy manually via the -x option but if that proxy will not apply to all situations, then I guess you're outta luck.

More here:

http://curl.haxx.se/docs/faq.html#Does_curl_support_Javascript_or


Forum|alt.badge.img+12
  • Valued Contributor
  • 157 replies
  • December 3, 2015

I think you could use a script:

#!/bin/sh

networksetup -setautoproxyurl Ethernet http://link/to.pac

Forum|alt.badge.img+9
  • Contributor
  • 125 replies
  • December 3, 2015

You would need to find the address of the proxy server that the PAC file points to when it is executed, then set your environment variables (http_proxy, https_proxy) to point to that server.

If you have Kerberos authentication enabled on your proxy, you should be able to just do a kinit to get a Kerberos ticket, then open Safari and go to Google to generate a kerberos ticket for the proxy. You can confirm that a ticket was issued by using klist. Once complete, you can test using curl http://www.google.com. If done correctly, you'll get a long string of HTML/JavaScript. If not, you'll probably get a "host not found" or "proxy authentication required" error.

If you don't have Kerberos enabled, you would need to include credentials in the proxy environment variable string.


Forum|alt.badge.img+11
  • Author
  • Contributor
  • 33 replies
  • December 3, 2015

Thanks everyone for the replies!

The pac file for the OS is already set, and surfing the web is no problem. If you want to use terminal and curl a file that's where there is an issue.

so if I did

"curl --silent http://server.com"

this won't resolve, but if I take that url and stick it in a browser it does work.


Forum|alt.badge.img+9
  • Contributor
  • 125 replies
  • Answer
  • December 3, 2015

Just to clarify, you can permanently set your proxy URL for use with terminal commands, but it won't work with PAC files. Refer to How to set proxy environment variable in Unix/Linux if you aren't already aware of how to do this.


Forum|alt.badge.img+11
  • Author
  • Contributor
  • 33 replies
  • December 3, 2015

Thanks @dwandro92


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings