0

I need the Magento admin to be sent to a separate backend from the store. I have 2 issues:

  1. Don't know how to properly match both index.php/admin and /admin with a regex (index.php/admin works, as it is matching second location I have below);
  2. When I get Nginx to match the location (currently only /admin), I don't know how to properly forward the request so i get "File not found" from the backend as it is trying to open as a php file instead of sending to the main handler index.php.

This is what I currently have for the admin

location ~ ^/(admin|index.php/admin)/ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass server1:9000;
    #fastcgi_index index.php;
    include fastcgi_params;
}

This is the 2nd directive that is matching index.php/admin and the whole site

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass server2:9000;
    fastcgi_index index.php;
    include fastcgi_params;
}
hernandes
  • 46
  • 4

1 Answers1

1

Instead of using two separate location directives I placed an if clause inside a single location:

location ~ \.php$ {
  try_files $uri =404;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass server2:9000;
  if ($request_uri ~ /admin/) {
    fastcgi_pass server1:9000;  
  }
  fastcgi_index index.php;
  include fastcgi_params;
}
hernandes
  • 46
  • 4
  • `if ($request_uri ~ /admin/) {` ended up being pretty useful in an unrelated redirect that I was looking for. Thanks! – Tyler V. Jul 29 '14 at 02:01