Enable the Magento API

in Nginx configuration

To enable the Magento API, first create the correct users.

The Magento API is supposed to work out-of-the box on Hypernodes, but due to clean-url-rewrites sometimes the API does not work and returns a 404 error.
To resolve this issue, some additional configuration is required.

Use the following snippet and save it as /data/web/nginx/server.api to configure Nginx for routing all API requests to api.php:

location /api {
    deny all;

    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;

This should work for both Magento 1 and Magento 2.

NB: If you don’t want to update IP addresses in all config files with every change of IP address, you can choose to use include files.