Q:

Accessing multiple services using single url docker-compose

I am using docker-compose to deploy multiple microservices in flask. Here is the compose code
version: '3'

services:
  test-api:
    volumes:
      - ./test-api:/test-api
    build: test-api
    ports:
      - "5000:5000"

  redis:
    image: "redis:alpine"

  search:
    volumes:
      - ./seach:/search
    environment:
      - HTTP_PORT=5000
      - REDIS_URL=redis://redis:6379/0
    build: search
    ports:
      - "5001:5000"
    link:
      - redis

Now I have to access this service from single URL eg: http://example.com/test-api or http://example.com/search, but I am unable to figure it out since the 2 services are running are on 2 different ports. I know I need to use nginx and configure it so that I can access them. But I am not sure how to do that. Can someone help me with this or at least give me some docs to read so as to understand the routing?
Also both the services use /health to report the result of health-check. How do I access the health check for both the services?

A:

So for the people who are looking for a quick solution, here is my nginx file
http {

    server {

        listen 80;

        location /test {
            proxy_pass http://test-api:5000;
        }
        location /search {
            proxy_pass http://search:5000;
        }
        location /health-test {
            proxy_pass http://test-api:5000/health;
        }
        location /health-search {
            proxy_pass http://search:5000/health;
        }
    }
}

