Comment puis-je configurer DNS pour que mon conteneur php-fpm sache envoyer certains hôtes au conteneur nginx avec docker-compose?

#1
I have two containers:

nginx

php71-fpm

I have these two that work great.

I have a REST API that I am developing, it is a different project.

I need my web application to be able to send API calls to this local.api.myproject.com

However, php-fpm doesn't know how to fix it.

Should I set up a DNS server container and make php-fpm use the DNS server?

And does the DNS server route specific hosts to nginx and then it all rolls back to Google 8.8.8.8?

TweakboxDoes anyone have an example of how to achieve this with docker-compose?
 
Dernière édition:

mike158

New Member
#2
Hello, @bearsethi96 Spotify Receiptify

To enable your php71-fpm container to resolve local.api.myproject.com without setting up a DNS server, follow these steps:

Create a Docker network to allow containers to communicate with each other.

Define your services (nginx, php71-fpm, and the API) in the Docker Compose file and ensure they are on the same network.

Configure Nginx to route the requests to your API.

Example Explanation:
Create a Docker Network: Define a network in your Docker Compose file to allow your containers to communicate.

Set Up Services
nginx: This will handle incoming requests.

php71-fpm: Your PHP application server.

API: Your REST API service.

Configure Nginx:
Configure Nginx to route requests for local.api.myproject.com to the API container.

Docker Compose Configuration:
Define a network named mynetwork in your Docker Compose file.

Ensure all services (nginx, php71-fpm, API) are attached to this network.


I hope this will help you out
Regards
mike
 
Dernière édition:
Haut