craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

Nameserver issue, when request a host with CURL #307

Closed yanickrecher closed 3 years ago

yanickrecher commented 3 years ago

Description

When try to request a host(in this example ws-vakanz.sopweb.ch) via CURL i get a error by using curl_error() Could not resolve host: ws-vakanz.sopweb.ch.

That never happen with Nitro(multipass) or Homestead/Vagrant.

I found out it has something to do with the configured nameserver in docker, so i changed the nameserver in /etc/resolv.conf to 8.8.8.8 (instead of 127.0.0.11) After that, craft was not able to connect to the DB but the CURL request for this host was working.

Then i tried other hosts, like: google.com (works with both Nameserver 8.8.8.8 and 127.0.0.1) nzz.ch (works with both Nameserver 8.8.8.8 and 127.0.0.1)

I am not experienced in that, but it looks like some config stuff with nameserver should be improved. Or the Provider of the API block somting (not sure about that, why else should that happen specially to this host).

Steps to reproduce

$cURLConnection = curl_init();
curl_setopt($cURLConnection, CURLOPT_URL, 'https://ws-vakanz.sopweb.ch');
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded' ));
$curlResponse = curl_exec($cURLConnection);

if ($curlResponse) {
    echo "works";
    var_dump($curlResponse);
} else {
    echo curl_error($cURLConnection);
}

curl_close($cURLConnection);

Additional info

Nitro CLI: 2.0.6 Nitro gRPC: 2.0.6 Docker API: 1.41 (1.12 min) Docker CLI: 1.41

yanickrecher commented 3 years ago

I changed nothing and today everything is working.