Welcome! Log In Create A New Profile

Advanced

Select upstream by subdomain

July 18, 2011 02:42PM
We are rewriting our app and would like to migrate accounts to the new back end in chunks, though not in alphabetical sequence. All accounts have unique subdomains. We have thousands of accounts so I don't think that putting the rewrite rules in manually would be feasible. I thought that maybe a key-value store would be a good solution, so I built nginx with the memc-nginx-module. Now I'm getting stuck.

Here's what I would like to happen: when a request comes in, ngnix uses the subdomain as the key and checks for its existence in memcached. If so, it gets passed to the new back end. If not, it goes to the old back end.

Here's what I have so far:

upstream memback {
server 127.0.0.1:11211;
keepalive 1024 single;
}

location @old {
proxy_pass localhost:7001;
}

location @new {
proxy_pass other_host:7001;
}

location / {
set $memc_key $arg_key;
memc_pass memback;
}

I can't figure out how to capture the response (404 or 200) from memcached and route the request to the proper back end. Am I going about this totally wrong? Thanks!
Subject Author Posted

Select upstream by subdomain

adamjt July 18, 2011 02:42PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 186
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