Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple projects and internal curl request #2180

Closed
fjugaldev opened this issue Jun 20, 2019 · 11 comments
Closed

Multiple projects and internal curl request #2180

fjugaldev opened this issue Jun 20, 2019 · 11 comments
Labels

Comments

@fjugaldev
Copy link

Info:

  • Docker version ($ docker --version): 18.09.2, build 6247962
  • Laradock commit ($ git rev-parse HEAD): 23193ba
  • System info (Mac, PC, Linux): Mac
  • System info disto/version: macOS Mojave 10.14.4

Issue:

I configured my laradock project in order to use multiples projects, so my directory structure looks like this:
/var/www/html/
- laradock
- project1
- project2

Everything is working fine, my containers are up and running an i can make http requests from outside using postman for example to each domain host like puf.loc and api.puf.loc and everything is ok.

My problem is that when project1 (puf.loc) wants to make an internal request using curl to project2 (api.puf.loc) im getting a connection refused message.

Making some research on google i found a post that indicates that i need to create add to the extra_hosts parameter in the docker-compose.yaml file for the php-fpm service the following entries:

  • "api.puf.loc:${DOCKER_HOST_IP}"
  • "puf.loc:${DOCKER_HOST_IP}"

And then run the following command:

docker-compose up -d --build nginx mysql redis beanstalkd memcached

But still no working.. i tried changing ${DOCKER_HOST_IP} with the ip of the nginx container and with no success. Have tried too with 127.0.0.1 and without response.

I understand that inside the container, when we make a request to a host like api.puf.loc, we need a entry in the /etc/hosts pointing to 127.0.0.1 but i can get working my two projects together inside the same container (multiple projects)

Can anyone help me with this??

Thank you guys!


Expected behavior:

I need that my project1 (puf.loc), can make a internal request via curl to my project2 (api.puf.loc) using the laradock for multiple projects.


@lgfinfo
Copy link

lgfinfo commented Jul 15, 2019

I have the same issue.

@lgfinfo
Copy link

lgfinfo commented Jul 16, 2019

I fixed it like this :
php-fpm
extra_hosts:
- "dockerhost:${DOCKER_HOST_IP}"
- "tegonganzhuang.test:${DOCKER_HOST_IP}"
- "oauthserver.test:${DOCKER_HOST_IP}"

@semenikhin
Copy link
Contributor

extra_hosts does not help for me.
I solved it by adding network aliases for nginx:

      networks:
        frontend:
        backend:
          aliases:
            - project1.local
            - project2.local

@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Feb 2, 2020
@stale
Copy link

stale bot commented Feb 23, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Feb 23, 2020
@Erisbv-zz
Copy link

Erisbv-zz commented Apr 30, 2021

In any of these cases did you use curl? I can't run Curl between projects ...

@diogenesderm
Copy link

Eu consertei assim:
php-fpm
extra_hosts:

  • "dockerhost:${DOCKER_HOST_IP}"
  • "site.development:192.168.1.178"

@thiagovieiradev
Copy link

Eu consertei assim: php-fpm extra_hosts:

  • "dockerhost:${DOCKER_HOST_IP}"
  • "site.development:192.168.1.178"

Esse IP 192 é o seu IP local?

@diogenesderm
Copy link

Eu consertei assim: php-fpm extra_hosts:

  • "dockerhost:${DOCKER_HOST_IP}"
  • "site.development:192.168.1.178"

Esse IP 192 é o seu IP local?

Sim. No meu caso ficou assim.
"dockerhost:${DOCKER_HOST_IP}"
"site1.development:192.168.1.178"
"site2.development:192.168.1.178
"site3.development:192.168.1.178

@thiagovieiradev
Copy link

Eu consertei assim: php-fpm extra_hosts:

  • "dockerhost:${DOCKER_HOST_IP}"
  • "site.development:192.168.1.178"

Esse IP 192 é o seu IP local?

Sim. No meu caso ficou assim. "dockerhost:${DOCKER_HOST_IP}" "site1.development:192.168.1.178" "site2.development:192.168.1.178 "site3.development:192.168.1.178

Entendi. E como fazia o curl? Com o endereço mesmo ou IP? Tipo "http://site1.development/api/list" ou IP mesmo?

@grupoderaca
Copy link

Eu consertei assim: php-fpm extra_hosts:

  • "dockerhost:${DOCKER_HOST_IP}"
  • "site.development:192.168.1.178"

Esse IP 192 é o seu IP local?

Sim. No meu caso ficou assim. "dockerhost:${DOCKER_HOST_IP}" "site1.development:192.168.1.178" "site2.development:192.168.1.178 "site3.development:192.168.1.178

Entendi. E como fazia o curl? Com o endereço mesmo ou IP? Tipo "http://site1.development/api/list" ou IP mesmo?

No CURL eu utilizo assim: http://site1.development:8081/api/list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants