Setting "terminals" proxy?

bentoms
Release Candidate Programs Tester

Hi all,

An earlier e-mail reminded me of something that's been bugging me.

How do you set the proxy that "terminal" uses?

My new environment has 1 proxy that uses NTLM & another that just logs.

Users use the NTLM one, but servers etc use the other.

Thing I've found is that whilst a proxy is set via system prefs... Terminal doesn't seem to respect it.

Any ideas?

(this may help the issue of the jamf binary not respecting proxies too)

Regards,

Ben.

15 REPLIES 15

Not applicable

The jamf binary uses curl to check for updates. Curl knows nothing about Mac OS X proxies; only the environment variables (such as http_proxy).

jarednichols
Honored Contributor

http_proxy=http://your.proxy.server:port/
Export http_proxy

j
-- Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436

Not applicable

Something like below?
/usr/sbin/networksetup -setautoproxyurl $networkinterface $proxyURL

where variables could be
networkinterface="ethernet"
proxyURL=http://blahablah.url:port or a_script_path

Not applicable

Well, that would set the Mac OS X proxies, but it would not set the proxies that are used by terminal-based programs like curl. You'd need to use something like this:

export http_proxy=http://your.proxy.server:port/

And you'd have to use it in the shell where you run the jamf binary, sometime before calling the binary. Or you could set it globally by adding it to some files in /etc, but when I tried that, it seemed to mess other things up.

bentoms
Release Candidate Programs Tester

Thanks all i didn't have a chance to look at it today... I had issues creating a cs5 pkg... But now I've realised the proxy was probably the issue!

Regards,

Ben.

Not applicable

You are right, that would not do it for terminal. Although 'curl' already has params that can be used to give it proxy I know that's not your point. So, this is how I was able to make curl work:

echo "export HTTP_PROXY='http://myproxy:port'" >>/etc/profile
echo "export http_proxy='http://myproxy:port'" >>/etc/profile

Interestingly exporting http_proxy alone did not do it for me...

Adil

bentoms
Release Candidate Programs Tester

So you can't set it globally?

Regards,

Ben.

Not applicable

Actually, that's not what I am saying. I think below might be what you need to set it globally as /etc/profile seems to be read by all other profiles.

Adil

bentoms
Release Candidate Programs Tester

Thankyou!

I'll test tomorrow.

Regards,

Ben.

Not applicable

Indeed, /etc/profile is read by all shells when they load, for every user (even in single-user mode, I think). This is the best place to put any environment variables that need to be truly global. That's why $PATH is set in there.

bentoms
Release Candidate Programs Tester

well i made the change but no joy.

will keep trying..

bentoms
Release Candidate Programs Tester

fyi.. i've been testing this by trying to download instadmg (svn checkout http://instadmg.googlecode.com/svn/trunk instadmg) & when on LAN it cannot connect... on ADSL it works fine.

bentoms
Release Candidate Programs Tester

looks like you also need to do the same for /etc/bashrc as it is used for non-login terminal windows.. so this is what i had to do..:

echo "export HTTP_PROXY="http://10.1.2.108:8080"" >>/etc/profile
echo "export http_proxy="http://10.1.2.108:8080"" >>/etc/profile
echo "export https_proxy="http://10.1.2.108:8080"" >>/etc/profile
echo "export HTTPS_PROXY="http://10.1.2.108:8080"" >>/etc/profile

echo "export https_proxy="http://10.1.2.108:8080"" >> /etc/bashrc
echo "export http_proxy="http://10.1.2.108:8080"" >> /etc/bashrc
echo "export HTTP_PROXY="http://10.1.2.108:8080"" >> /etc/bashrc
echo "export HTTPS_PROXY="http://10.1.2.108:8080"" >> /etc/bashrc

that seems to work for pinging www.apple.com, but looks like redirection does not work (so apple.com doesn't work neither does 
svn checkout http://instadmg.googlecode.com/svn/trunk instadmg).

Not applicable

The proxy environment variables are commonly supported by command-line tools, but they are not enforced in any way. It is up to each software developer to write code to check them.
On Apr 15, 2011, at 4:15 AM, Ben Toms wrote:

In the case of Subversion, the proxy must be set in its configuration file - the env vars are not consulted. See http://subversion.apache.org/faq.html#proxy

-- Ben

tkimpton
Valued Contributor II

Can someone please explain how to do this?

I have looked on the url and this is not helpful. I wish to know how to add this to the configuration file but which configuration file and where?

I am trying to download InstaDMG behind a proxy and i also have a developer that wishes to use the commandline to install these two apps but experiencing problems because of the proxy

I have a direcory ~/.subversion if that helps

Thanks