url rewriting - nginx to forward request to different port depending on the url -


i trying write nginx conf redirect requests different port depending on url being passed. example, want redirect http://ip/some/path/1/do/action http://ip:8501/some/path/do/action , http://ip/some/path/2/do/action http://ip:8502/some/path/do/action

perhaps can below not want since need duplicate 20 times..

probably need use rewrite , regular expression stuck since cannot find example.

location  /some/path/1 {   proxy_pass      http://127.0.0.1:8501;   proxy_set_header    host $host;   proxy_set_header    x-real-ip $remote_addr;   proxy_set_header    x-forwarded-for $proxy_add_x_forwarded_for;   proxy_set_header    x-forwarded-proto $scheme;   proxy_redirect http://127.0.0.1:8501 http://127.0.0.1:8501/some/path; }  location  /some/path/2 {    proxy_pass      http://127.0.0.1:8502;   proxy_set_header    host $host;   proxy_set_header    x-real-ip $remote_addr;   proxy_set_header    x-forwarded-for $proxy_add_x_forwarded_for;   proxy_set_header    x-forwarded-proto $scheme;   proxy_redirect http://127.0.0.1:8502 http://127.0.0.1:8502/some/path; } 

i appreciate of input. thank you!


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -