I developed a multi-container application running on Torizon OS.
One of them runs a python application and the other one runs a node.js application.
Both of them expose their own web server.
I would like exposing some APIs of the two web servers to external clients (i.e., clients that runs on different devices connected to the same LAN) under a single endpoint.
For this reason I’ve been thinking to a reverse proxy.
Is this a suitable idea?
Is there any docker container to do this?
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello!
Using a reverse proxy is indeed a suitable solution for your requirement to expose APIs from multiple containers under a single endpoint. A reverse proxy can route incoming requests to the appropriate backend service based on the request URL or other criteria, effectively consolidating access to your Python and Node.js applications.
A popular choice for a reverse proxy in Docker environments is Nginx. Nginx can be easily deployed as a Docker container and configured to route requests to your Python and Node.js applications.
Here’s a basic outline of how you can set up Nginx as a reverse proxy using Docker Compose on Torizon:
Create a Docker Compose File: Define your services in a docker-compose.yml file. Include your existing Python and Node.js services, and add a new service for Nginx.
Configure Nginx: Create an Nginx configuration file to define the reverse proxy rules. This file will specify how requests should be routed to your Python and Node.js applications based on the URL path or other criteria.
Mount the Configuration: Use a volume in your Docker Compose file to mount the Nginx configuration file into the Nginx container.
Network Setup: Ensure all containers are on the same Docker network to allow Nginx to communicate with your application containers.
Expose Ports: In the Docker Compose file, expose the necessary ports for Nginx to listen for incoming requests.
Here is a simplified example of what your docker-compose.yml might look like:
In this setup, nginx.conf should be configured to route requests to python-app and nodejs-app based on the desired criteria.
This approach will allow you to manage your multi-container application efficiently on Torizon, providing a single endpoint for external clients to access your APIs.
Best regards, Toradex AI Assistant.
Please, also check if these links can help you solve your problem: