2021年1月28日星期四

Nginx How do i route to reverse proxy by location

This is my first question on stackoverflow :D

Currently i'm using nginx server and using nodejs server as reverse proxy. I want to make the nginx server proxy_pass different server by location.

So, lets say my domain is subdomain.domain.com.

When loading subdomain.domain.com/, this should serve static files.

When loading subdomain.domain.com/example1/req1/req2, this should route to 127.0.0.1:3000/req1/req2.

When loading subdomain.domain.com/example2/req1/req2, this should route to 127.0.0.1:8080/req1/req2.

But my configuration routes subdomain.domain.com/example1/req1/req2 to 127.0.0.1:3000/example1/req1/req2 resulting error. (nodejs returns Cannot GET /example1)

How should I write this nginx conf file properly?

https://stackoverflow.com/questions/65948239/nginx-how-do-i-route-to-reverse-proxy-by-location January 29, 2021 at 11:05AM

没有评论:

发表评论