54

I'm in a Microsoft IE environment, but I want to use cygwin for a number of quick scripting tasks.

How would I configure it to use my windows proxy information? Ruby gems, ping, etc are all trying to make direct connections. How can I get them to respect the proxy information that IE and firefox use?

MattK
  • 1,521
  • 1
  • 12
  • 25

5 Answers5

58

Just for the records if you need to authenticate to the Proxy use:

export http_proxy=http://username:password@host:port/

Taken from: http://samueldotj.blogspot.com/2008/06/configuring-cygwin-to-use-proxy-server.html

Mohsen Nosratinia
  • 9,844
  • 1
  • 27
  • 52
Vlax
  • 1,447
  • 1
  • 18
  • 24
  • 9
    Similarly, you have to export `https_proxy` to the same value to make HTTPS connections work. – Bram Schoenmakers Mar 07 '12 at 09:08
  • 4
    Note that if your username or password contain special characters you can enclose them in single quotes. e.g. http://'domain\username':'p@$$word'@host:port/ – 79E09796 Feb 01 '13 at 17:47
  • @79E09796 enclosing them in single quotes `did not` help me ! Escaping the special characters worked !! – srini Jun 27 '13 at 15:20
  • @srini Strangely escaping didn't work for me and it took me some time to find out about the single quotes, I wonder what the difference is? (I'm on Windows 7, using a NTLM corporate proxy) – 79E09796 Jun 27 '13 at 16:40
  • ...and `ftp_proxy` for FTP. – StellarVortex Apr 25 '14 at 08:06
  • @79E09796 what did you do exactly? was it `export http_proxy=http://localhost:53128/` as I'm on Windows 7, using cntlm behind a corporate proxy as well. this is my git setup on cygwin `$ git config --global http.proxy http://localhost:53128` – HattrickNZ Jun 20 '14 at 01:20
  • as above specify the username and password e.g http_proxy=http://'domain\HattrickNZ':'p@$$word'@localhost:53128 my trick was just finding out that you can use single quotes if you have special characters in your password. – 79E09796 Jun 23 '14 at 16:31
  • Also if there is no username/password for the proxy, simply omit the `username:password@` part, making it just `http_proxy=http://host:port/` and `https_proxy=https://host:port/` – FriendFX Sep 10 '14 at 03:04
29

Most applications check one of the following environment variables (gem even checks both), so try putting this code in your .bashrc:

proxy=http://host.com:port/
export http_proxy=$proxy
export HTTP_PROXY=$proxy
Bruno De Fraine
  • 45,466
  • 8
  • 54
  • 65
7

I doubt that your corporate firewall allows PING, but the others all appear to be one form of http or another. On a Linux system, you can set your HTTP proxy as an environment variable, so in bash, type:

export http_proxy=http://www.myproxy.com:3128

There is a similar environment variable for FTP (ftp_proxy).

Steve Moyer
  • 5,663
  • 1
  • 24
  • 34
6

If I just use what Vlax and Mohsen Nosratinia suggested (export http_proxy=http://yourusername:yourpassword@host:port/), it will only work half of the programs (some of the installs will work but not all) for my company.

By adding another line it will work for all (maybe most) at least in my situation.

export http_proxy=http://yourusername:yourpassword@host:port/
export https_proxy=$http_proxy
ian0411
  • 4,115
  • 3
  • 25
  • 33
5

You can also set it on Windows environment variables and cygwin will load it on startup (little bonus: any command prompt on windows will also have it set).

nyedidikeke
  • 6,899
  • 7
  • 44
  • 59
Luis
  • 71
  • 1
  • 1