We have nginx server that redirect service requests by server_name using
proxy_pass to upstream:

nginx conf:

server {
  server_name requestsproxy-rest.us.example.com;
....
location / {
.....
    proxy_pass http://Requestsproxy-Rest;

and the upstream file:

upstream Requestsproxy-Rest {
  least_conn;
  server 10.1.1.1:29257 max_fails=4 fail_timeout=1s weight=1;

  server 10.1.1.2:21591 max_fails=4 fail_timeout=1s weight=1;

 }

We want to create nginx rewrite rule that will be able to be accessed via "
api.example.com/service/{domain}" and the nginx will forward/redirect the
request to different address by the {service} to the nginx.

for example:

api.example.com/service/{requestsproxy-rest} -->
{requestsproxy-rest}.us.example.com

how do you think we can manage it via nginx configurations?

I try something like:

> location /{(?:[a-zA-Z0-9][a-zA-Z0-9]+$)} {
>       rewrite (.*) $1.example.com;


Thanks in advanced.


-- 

[image: photo]

Eli Fish

Devops Engineer

m: +(972) 50-5781700

e: ef...@yotpo.com| Check out the Yotpo blog!
<https://www.yotpo.com/blog/?utm_source=gmail&utm_medium=email&utm_campaign=signature>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to