Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active August 22, 2024 16:57
Show Gist options
  • Select an option

  • Save mklooss/7300787 to your computer and use it in GitHub Desktop.

Select an option

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

Kamik commented Jun 13, 2014

Copy link
Copy Markdown

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

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

@drosanda

drosanda commented Oct 1, 2014

Copy link
Copy Markdown

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

@mklooss

mklooss commented Mar 16, 2015

Copy link
Copy Markdown
Author

I've updated this gist

@joostvanveen

joostvanveen commented Feb 22, 2017

Copy link
Copy Markdown

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
Copy Markdown

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

@JosephMaxwell

Copy link
Copy Markdown

Thank you. This worked great for me.

@geoffjukes

Copy link
Copy Markdown

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