Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active August 2, 2019 12:05
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mklooss/7300787 to your computer and use it in GitHub Desktop.
Save mklooss/7300787 to your computer and use it in GitHub Desktop.
nginx magento configuration for API Calls
location /api {
rewrite ^/api/rest /api.php?type=rest last;
rewrite ^/api/v2_soap /api.php?type=v2_soap last;
rewrite ^/api/soap /api.php?type=soap last;
}
@Kamik
Copy link

Kamik commented Jun 13, 2014

Works for you?
/api/rest - is ok.
soap and v2_soap - not ok.

api/v2_soap" failed (2: No such file or directory)

@drosanda
Copy link

drosanda commented Oct 1, 2014

Soap v1 and v2 not working. I've used Magento 1.9.0.1.

@mklooss
Copy link
Author

mklooss commented Mar 16, 2015

I've updated this gist

@joostvanveen
Copy link

joostvanveen commented Feb 22, 2017

Thanks for the gist. Not much documentation on this, I am afraid.

On Byte Hypernode, which is also nginx, the above code downloads the file api.php. So it seems the path is somehow not processed by the PHP interpreter.

Do you happen to have any experience with that? Or a suggestion as to what is happening?

EDIT
Found the answer. Byte Hypernode is running on a php/fpm nginx configuration. You'd need this:

location /api {
   rewrite ^/api/rest /api.php?type=rest last;
   rewrite ^/api/v2_soap /api.php?type=v2_soap last;
   rewrite ^/api/soap /api.php?type=soap last;

   location ~ \.php$ {
       echo_exec @phpfpm;
   }
}

@martinboy
Copy link

The xmlrpc support need to be added
rewrite ^/api/xmlrpc /api.php?type=xmlrpc last;

@JosephMaxwell
Copy link

Thank you. This worked great for me.

@geoffjukes
Copy link

In one:

  location /api {
    rewrite ^/api/(\w+).*$ /api.php?type=$1 last;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment