3

I use laradock.

I created multiple projects. One project is one microservice.

I need to use guzzle http to get data from one microservice to another.

In laradock/nginx/sites I configured all virtual host.

Each project(microservice) work fine separatly.

But when I try get data from one container for another:

$url = "test.localhost/users";

        $client = new \GuzzleHttp\Client();
        $request = $client->get($url);
        $response = $request->getBody();

        return json_decode($response->getContents(), true);

I got an error:

GuzzleHttp \ Exception \ ConnectException cURL error 7: Failed to connect to test.localhost port 80: Connection timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

I think this is problem with docker.

I tried:

networks:
 frontend:
  aliases:
   - test.localhost
   - test2.localhost
 backend:
  aliases:
   - test.localhost
   - test2.localhost

But it didn't helped.

first
  • 482
  • 4
  • 17

1 Answers1

0

If you using laradock please see your site on hosts and then list it on laradock/docker-compose.yml, not in nginx: section but in workspace:. After that please restart the docker by type docker-compose down and then up again. It is a common problem when you try to create an authentication i hope this will help.

  networks:
    frontend:
      aliases:
        - mysite.test
        - mysite2.test
        - mysite3.test
    backend:
      aliases:
        - mysite.test
        - mysite2.test
        - mysite3.test
KEKUATAN
  • 948
  • 7
  • 21