0

I am new to server stuff, i want to host multiple rest service using docker and nginx.

Let's say i have three service that runs on 8180, 8181 and 8182. I am able to forward request to one port but i have no idea how to tell nginx to forward to specific ports based on the url.

Lets say:

https://testsite.com/api/v1/products -> access product service

https://testsite.com/api/v1/orders -> access order service

https://testsite.com -> access webpage (vuejs)

Do i need to create api-gateway and route them by its url and runit inside docker?

Are there any best practice on how to this?

Thanks.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
Fen
  • 1
  • yes! i am looking for this answer actually. but is it a good practice to use api-gateway to solve this problem? (just wondering) – Fen Dec 15 '22 at 06:21
  • 1
    You cannot come here and expect full education on how to use nginx, as that's your homework. In short you need a `server` block to handle `https://testsite.com` and then within it, multiple `location` blocks for different URL patterns so that requests can be forwarded to services (`proxy_pass`). There are books and tutorials you can find over the internet, and examples like https://www.nginx.com/resources/wiki/start/topics/examples/full/ – Lex Li Dec 15 '22 at 06:50

0 Answers0