mercredi 19 février 2020

NGINX A/B test with split_clients and rewrite

I have the next dummy testing config for split_clients:

split_clients "${cookie_landing}" $landing {
  50%        test;
  *          main;
}

server {
  listen 80;

  location / {
    rewrite / /$landing;
  }

  location = /test/ {
    internal;
    proxy_pass http://test.domain.ru/;
  }

  location = /main/ {
    internal;
    return 200;
  }

}

which can be run with:

docker run -it -d -v test.conf:/etc/nginx/conf.d/default.conf -p 8080:80 --name nginx openresty/openresty:1.15.8.2-7-alpine

With config from the above none of the internal locations works. If cookie set up, requests pass to /main with the following error:

rewrite or internal redirection cycle while processing "/main"

Without the cookie, requests pass to localhost/test/ (without port) with 301 code and that's it.

What is wrong with my config? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire