harbor run -t LiteCoder/nginx-multiservice-docker-composeharbor download LiteCoder/nginx-multiservice-docker-composeDeploy a multi-container web application using Docker Compose, with Nginx as a reverse proxy routing requests to three backend services based on URL paths.
Create the following directory layout under /app:
/app/
├── docker-compose.yml
├── nginx/
│ └── nginx.conf
├── auth-svc/
│ ├── Dockerfile
│ ├── app.py
│ └── requirements.txt
├── data-svc/
│ ├── Dockerfile
│ ├── app.py
│ └── requirements.txt
└── static-svc/
├── Dockerfile
└── html/
└── index.html
1. auth-svc (Authentication Service)
POST /auth/login — accepts JSON body {"username": "<string>", "password": "<string>"}. If username is admin and password is secret, return HTTP 200 with JSON {"token": "<any non-empty string>"}. Otherwise return HTTP 401 with JSON {"error": "Invalid credentials"}.GET /auth/health — return HTTP 200 with JSON {"status": "ok", "service": "auth-svc"}.2. data-svc (Data Processing Service)
POST /data/process — accepts JSON body {"numbers": [<list of numbers>]}. Return HTTP 200 with JSON {"sum": <sum>, "count": <count>, "average": <average>}. The average should be a float. If numbers is empty, return {"sum": 0, "count": 0, "average": 0}. If the request body is missing the numbers field or it is not a list, return HTTP 400 with JSON {"error": "Invalid input"}.GET /data/health — return HTTP 200 with JSON {"status": "ok", "service": "data-svc"}.3. static-svc (Static File Service)
GET /static/ should serve index.html.index.html file must contain the text Welcome to Static Service somewhere in the body./auth/ are proxied to auth-svc on port 5000./data/ are proxied to data-svc on port 5001./static/ are proxied to static-svc on port 80./app/docker-compose.yml must define at least four services: nginx, auth-svc, data-svc, static-svc.8080:80 on the nginx service.docker compose up --build -d from /app must start all services successfully.After docker compose up, the following requests must succeed:
GET http://localhost:8080/auth/health → 200, JSON with "service": "auth-svc"POST http://localhost:8080/auth/login with {"username":"admin","password":"secret"} → 200, JSON containing "token"POST http://localhost:8080/auth/login with {"username":"wrong","password":"wrong"} → 401GET http://localhost:8080/data/health → 200, JSON with "service": "data-svc"POST http://localhost:8080/data/process with {"numbers":[1,2,3]} → 200, JSON with "sum":6, "count":3, "average":2.0POST http://localhost:8080/data/process with {} → 400GET http://localhost:8080/static/ → 200, body contains Welcome to Static Service