How to configure routes and kong in a microservices environment with nginx

We have nginx in front of kong-dbless (declarative config) server. Nginx is configured to direct any requests coming with path ‘/api’ to the kong server port 8000. We have multiple spring boot applications each with their own context-paths. For e.g. the products app has the context-path as /products-app while the payments app has it as /payments-app. Each app has rest-apis exposed that we want to go through kong.
So the apis paths exposed from kong should be
GET /api/payment-modes
GET /api/transactions
POST /api/payments/{id}/transactions

GET /api/products
GET /api/stores
PATCH /api/products/{1}

How should my kong declarative config file look like? Would I need to add one service per api that’s exposed by each of the apps? That looks too much.

My first version of the config file looks like below - It doesn’t work since /api/products should be redirected to http://172.19.0.1:8080/products-app/products and /api/payment-modes to
http://172.20.0.1:8080/payments-app/payment-modes.

  1. How do I achieve the above redirect?
  2. How do I specify dynamic paths?

Thanks.

services:
  - name: products-app
    url: http://172.19.0.1:8080/products-app
    routes:
      - name: products-app-route
        paths:
          - /api/products
          - /api/stores
          # how do I specify dynamic path for /api/products/{id}/items?
  - name: payments-app
    url: http://172.20.0.1:8080/payments-app
    routes:
      - name: payments-app-route
        paths:
          - /api/payment-modes
          - /api/transactions
          - /api/payments
          #how do I specify path for /api/payments/{id}/transactions?

hi @shahamit - you can use regex in your route paths:

My config worked after I added strip_path: false to the route. It seems it was by default true