We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46434
    • 22 Posts
    Has anybody used used the nginx split_clients module (http://nginx.org/en/docs/http/ngx_http_split_clients_module.html) for A/B testing with ModX?

    For example, say I have a resource with a friendly url of http://example.com/myresourcecontainer/. I would like to use the split_clients module to send some traffic to http://example.com/beta/myresourcecontainer/.
      • 46434
      • 22 Posts
      Does anybody have any knowledge of the nginx split_clients module?
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        Mark Hamstra Reply #3, 11 years ago
        The only A/B testing I've personally done used SimpleAB: https://www.modmore.com/extras/simpleab/

        To get split_clients to do your bidding, you might need to figure out how to combine it with the friendly urls configuration in your nginx conf (typically the try_files bit). From that (very sparse) documentation it sounds like it only fires on the index page, making it request index.html, index.one.html or index.two.html... that doesn't sound like it supports arbitrary dynamic urls handed off to php-fpm or an apache reverse proxy.
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 46434
          • 22 Posts
          Thanks for the reply. That's pretty much what I gathered from the documentation as well.

          I have the following in my nginx.conf:
          http {
              split_clients $remote_addr $beta {
                  100%    "/beta";
                  *       "";
              }
          }
          
          server {
              ...
              location @modx {
                  rewrite ^/(.*)$ /index.php?mq=$1 last;
              }
              
              location / {
                  try_files $uri $uri/ @modx;
              }
          }


          I tried modifying the "location /" directive to be the following:
          location / {
              try_files $uri $beta$uri/ @modx;
          }


          However that doesn't seem to work, and I'm not versed enough in the specifics of nginx to know why. It also messes with manager access as well as static asset requests, but I'd be able to handle those exceptions.