5

My Linux(redhat6) server has to use http proxy to connect to outside world. While it works for other things like wget, it doesn't work for cabal.

cabal update -v3

shows errors like this:

407 - proxy authentication required cabal: Failed to download http://hackage.haskell.org/packages/archive/00-index.tar.gz : ErrorMisc "Unsucessful HTTP code: 407"

I tried to change http_proxy environment variable to format like http:// user: passwd at proxy:port, but it doesn't work either.

The same problem has been asked here

But I'm not allowed use a proxy server like polipo, is there any other way to make cabal work behind a proxy?

Community
  • 1
  • 1
swang
  • 5,157
  • 5
  • 33
  • 55

3 Answers3

2

You can use cntlm to talk to proxy. It will handle authentication issues. After configuring and installing cntlm, set up the new environmental variable by modifying http_proxy, https_proxy etc.

Your cabal command should work after that.

Sibi
  • 47,472
  • 16
  • 95
  • 163
2

some detailed procedure here:

  1. Download cntlm from here It's a c program with no other dependencies so very easy to make, just follow the instructions in the downloaded package.

  2. After installing cntlm, follow this answer from Colonel Panic. Obviously on linux you need to change cntlm.exe to ./cntlm, I named the configure file cntlm.conf

  3. The default listen port for cntlm is 3124, if you can't use that port, change it to something else like 53124, then add this to your cntlm.conf or cntlm.ini file:

    Listen              127.0.0.1:53124
    
  4. Start cntlm in the background:

    
    ./cntlm -c cntlm.conf
    
  5. Change your http_proxy environment variable to talk to the cntlm process rather than the real proxy.

    
    export http_proxy=http:// 127.0.0.1:53124
    

That's it, cabal will work as good as ever.

Community
  • 1
  • 1
swang
  • 5,157
  • 5
  • 33
  • 55
  • `wget` respects the environmental variable `http_proxy` and others. So it should work if you set up the proper environment variables. – Sibi Apr 20 '14 at 08:50
  • I set http_proxy properly but not https_proxy, maybe I messed up somewhere, will have another look when i get back to the office. – swang Apr 20 '14 at 11:02
  • You may also want to check up the doc of wget. It seems to have options for setting up proxy. In my office, I work under proxy and `wget` has no problems with cntlm once I set up the environmental variables properly. :) – Sibi Apr 20 '14 at 11:04
  • yes you are right, don't know why it didn't work the first time, but it definitely works now, edited my own answer – swang Apr 22 '14 at 15:10
-1

You can also setup the http_proxy directly in the system setting:

http_proxy=http://username:password@hostname:port
Mogsdad
  • 44,709
  • 21
  • 151
  • 275