Score:0

Port Forwading by Url? (Nginx)

bq flag
Fen

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.

Fen avatar
bq flag
Fen
yes! i am looking for this answer actually. but is it a good practice to use api-gateway to solve this problem? (just wondering)
Lex Li avatar
vn flag
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/
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.