title: Multiple fpm socket in one nginx site by locations
body: <p>Imagine a default site in nginx</p>
  
  <pre><code>server {
      listen 80;
      server_name example.com;
  }
  
  server {
      listen 80 default_server;
      client_max_body_size 0;
      server_name _;
  
      index index.php index.html index.htm;
      set $root_path '/www/public';
      root $root_path;
  
      try_files $uri @rewrite;
  
      rewrite ^/(?!api/)(.*)/$ /$1 permanent;
  
      location @rewrite {
          rewrite ^/(.*)$ /index.php?_url=/$1;
      }
  
      location ~ \.php$ {
          fastcgi_index /index.php;
  
          ##### I THINK LOCATION CONFIG MUST COMES HERE #####
          fastcgi_pass unix:/var/run/php/xxxx.sock;
          ###################################################
  
          include fastcgi_params;
          fastcgi_split_path_info           ^(.+\.php)(/.+)$;
          fastcgi_param PATH_INFO           $fastcgi_path_info;
          fastcgi_param PATH_TRANSLATED     $document_root$fastcgi_path_info;
          fastcgi_param SCRIPT_FILENAME     $document_root$fastcgi_script_name;
          access_log syslog:server=loghost,facility=local7,tag=nginx,severity=info syslogformat if=$dolog;
      }
  }
  </code></pre>
  
  <p>We need to separate urls after rewrite (to index.php) and pass them to different fpm sockets<br>
  For example I want to use<br>
  <code>fastcgi_pass unix:/var/run/php/1111.sock;</code> for urls like <code>^/action-1/</code><br>
  and<br>
  <code>fastcgi_pass unix:/var/run/php/2222.sock;</code> for anything else  </p>
  
  <p>How can I do this ? Appreciate any help</p>