How to set the proxy for Cabal

PROXY

I am using Ubuntu behind a (Windows) proxy. I would like to use the cabal utility.

jem@Respect:~$ cabal update
Config file path source is default config file.
Config file /home/jem/.cabal/config not found.
Writing default configuration to /home/jem/.cabal/config
Downloading the latest package list from hackage.haskell.org
Warning: invalid http proxy uri:
"http://domain\\user:pass@internetproxy:3128/"
Warning: proxy uri must be http with a hostname
Warning: ignoring http proxy, trying a direct connection
^C

The proxy URL has been read from the environment. My proxy requires authentication, but cabal wants the proxy URL to start with a hostname, so perhaps it will prompt me for credentials…

jem@Respect:~$ http_proxy=http://internetproxy:3128/ cabal update
Downloading the latest package list from hackage.haskell.org
No action for prompting/generating user+password credentials  provided (use: setAuthorityGen); returning Nothing
cabal: Failed to download index 'ErrorMisc "Unsucessful HTTP code: (4,0,7)"'

What is setAuthorityGen and how do I use it? More importantly, can I enable access via the authenticating proxy? Will I need to tunnel?

Best Answer

My standard approach to ISA proxies is to configure a local authenticating proxy like cntlm. After installing cntlm on your Ubuntu machine, you configure it to authenticate via NTLM at the ISA proxy with your Windows username and password. Then you set the HTTP_PROXY variable to http://localhost:3128 (i.e. the port that cntlm is listening to).

The advantage of this approach is that only one program has to deal with the Windows proxy. All other programs can pass through by using cntlm as their gateway.

Related Question