Welcome! Log In Create A New Profile

Advanced

redirect from api.example.com/service/{domain} to other servers

Eli Fish
April 09, 2019 10:10AM
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: efish@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
Subject Author Views Posted

redirect from api.example.com/service/{domain} to other servers

Eli Fish 276 April 09, 2019 10:10AM

Re: redirect from api.example.com/service/{domain} to other servers

Maxim Dounin 157 April 09, 2019 10:24AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready