SuiteCRM REST API v8 Not working with Nginx (ubantu 18.0)

Hello,

I try to get access token Using REST API v8 but getting 404 . error.

I have change nginx conf file for rewrire rules but its not working .


 location /api {
      rewrite ^/api/(.*?)$ /lib/API/public/index.php/$1 break;
   }

Really appreciate the help on the same.

Thanks

You get the 404 error doing what, exactly?
Anyway please be aware that SuiteCRM on nginx can work but is unsupported, so it requires a few changes to the codebase (there are other posts on the forum with details)

Yes

Getting 404 error. Suitecrm Working fine with nginx but i think its nginx rewrite rule issue.

Thanks

To make the API work in Nginx add this to your config:

        location ~ /Api/ {
                index   index.php;
                try_files $uri @rewrite_api;

                location ~ \.php {
                        include snippets/fastcgi-php.conf;
                        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                }
        }

        location @rewrite_api {
                rewrite ^/Api/(.*)?$    /Api/index.php/$1       last;
        }
1 Like

what config file please? and what is its directory

It should be placed in your site configuration on your nginx webserver. /etc/nginx/sites-enabled/…

Alternatively, you may be able to use the direct URLS to the API (rather than the ‘modified nice looking ones’) as outlined in:

This means that you can avoid the shortened https://mysite.com/Api/access_token and instead use the full path https://mysite.com/Api/index.php/access_token

Similarly for using the V8 Api, replace https://mysite.com/Api/V8/module and instead use the full path https://mysite.com/Api/index.php/V8/module