Skip to content

Instantly share code, notes, and snippets.

@ozh
Created March 24, 2014 23:30
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ozh/9751639 to your computer and use it in GitHub Desktop.
Save ozh/9751639 to your computer and use it in GitHub Desktop.
Using Composer behind a proxy

Define the proxy in the CLI :

$ export https_proxy='87.248.188.202:8080'
$ export http_proxy='87.248.188.202:8080'

Check proxy :

$ curl https://icanhazip.com
87.248.188.202

$ curl http://icanhazip.com
87.248.188.202

Install composer :

$ curl -sS https://getcomposer.org/installer | php

(alternative: just download https://getcomposer.org/composer.phar, duh)

Check composer :

$ php composer.phar diagnose
@ammarfrahm
Copy link

ammarfrahm commented Feb 9, 2018

In my case, i need to specify protocol and authentication credential in the environment variable.

$ export https_proxy='http://username:password@87.248.188.202:8080'
$ export http_proxy='http://username:password@87.248.188.202:8080

@shadyueh
Copy link

Thanx a lot! Forcing https_proxy to use http solved my problem.

@wagnermarques
Copy link

wagnermarques commented Jun 24, 2020

Hi guys,
I hope this is the right place to ask....

I think it is ok about be my composer is behind a proxy because composer diagnose says its ok...
But there are a problem "Cannot connect to HTTPS server through proxy "
I tryed to disable https but now works

Below is a print of this issue...

Best regards

composer-proxy-issue

@ozh
Copy link
Author

ozh commented Jun 24, 2020

@wagnermarques sorry man, this gist was notes I wrote down 6 years ago to solve a specific issue I had, I know nothing more than what is written here :)

@wagnermarques
Copy link

Ok, no problem... thanks...

@leandroximenes
Copy link

Thank you!!

I replace this :
php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \

for this:
curl -sS https://getcomposer.org/installer | php

in laravel sail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment