Search code examples
proxyddev

ddev behind corporate proxy


I want the ddev web container to use my corporate proxy settings. Else when i run composer diagnose i end up with this:

uid_1000@d24b5fb17f37:/var/www/html$ composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: [Composer\Downloader\TransportException] The "http://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out
Checking https connectivity to packagist: [Composer\Downloader\TransportException] The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit" file could not be downloaded: failed to open stream: Connection timed out
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: 

  [Composer\Downloader\TransportException]                                                                          
  The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out  


diagnose

And i can't use composer properly.

I need a way to pass the environnement variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY to the container, how can i achieve this?


Solution

  • Update :

    Well, after reading a bit of docker documentation, there is an existing way to define a proxy properly... See https://docs.docker.com/network/proxy/

    By creating on the host the file ~/.docker/config.json with

    {
     "proxies":
     {
       "default":
       {
         "httpProxy": "http://ip:port",
         "httpsProxy": "http://user:password@ip:port,
         "noProxy": "*.test.example.com,.example2.com"
       }
     }
    }
    

    then ddev restart docker will automatically set the needed ENV vars, lowercase and uppercase.

    With this, composer works, wget works. apt still doesn't works form inside the container, because it still need proxy settings in a /etc/apt/apt.conf.d/20proxyconf file, but it works from a .ddev/web-build/Dockerfile, i think that's enough :)