Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Can nginx route to oneself using different domains?

$
0
0
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?

Viewing all articles
Browse latest Browse all 4759

Trending Articles