Welcome! Log In Create A New Profile

Advanced

Can nginx route to oneself using different domains?

Posted by tatsuyaoiw 
Can nginx route to oneself using different domains?
December 10, 2014 04:32AM
Hello,

I'm trying to do A/B testing with nginx, and let's say I have one nginx instance on a host having three different domains, nginx-a, nginx-b, and nginx-c.

- /etc/hosts
---
192.168.50.10 nginx-a nginx-b nginx-c;
---

Now what I want to do is to proxy requests from a domain nginx-a to nginx-b or nginx-c using some weighted load balancing method. In the following example, the client request first should be sent to nginx-a, then 95% of requests are distributed to nginx-b (and finally, to backend-b) and 5% of them are to nginx-c (backend-c)

- nginx.conf
---
upstream backend-a {
server nginx-b:5000 weight=95;
server nginx-c:5000 weight=5;
}

upstream backend-b {
server server-b-1:9000;
server server-b-2:9000;
server server-b-3:9000;
}

upstream backend-c {
server server-c-1:9000;
server server-c-2:9000;
server server-c-3:9000;
}

http {
server {
listen 5000;
server_name nginx-a;
location /test {
proxy_pass http://backend-a;
}
}

server {
listen 5000;
server_name nginx-b;
location /test {
proxy_pass http://backend-b;
}
}

server {
listen 5000;
server_name nginx-c;
location /test {
proxy_pass http://backend-c;
}
}
}
---

My questions are:

1. Is it possible route to oneself as an upstream server using different domains?
2. (If possible) Does it cause any performance degradation compared with general proxying (required http connections are doubled, etc)?
3. (If not possible) Are there any alternative way of using weight for a group of upstreams?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 122
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready