# KREST API on nginx

**URL:** <https://community.spicecrm.io/t/krest-api-on-nginx/85>\
**Category:** Installation\
**Created:** [February 28, 2017, 6:44pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85 "2017-02-28T18:44:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dooferorg](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dooferorg](https://community.spicecrm.io/u/dooferorg)\
**Post date:** [February 28, 2017, 6:44pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/1 "2017-02-28T18:44:28Z")

</div>

Hi,

I’ve been working on getting SpiceCRM installed on nginx/PHP fpm.

I’ve downloaded KREST and the mobile module and installed them within the module loader.

In order to get the KREST test JSON to be returned correctly (from the [crmsite.com/KREST/sysinfo](http://crmsite.com/KREST/sysinfo) test) I added this to my nginx site config:

```
  autoindex off;
  location /KREST/ {
    if (!-e $request_filename){
       rewrite ^(.*)$ /KREST/index.php break;
    }

    try_files index.php?$query_string =404;
    allow all;

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 300;
    include fastcgi_params;
  }

```

Unfortunately even though that works, when I use the SpiceCRM mobile app I get:

‘Error Conencting’ (sic)

’ … Please ensure the url is correct and KREST extension is loaded …’

From modules it says that the KREST API is installed and the JSON from the sysinfo command seems to indicate that.

Anyone have any hints/thoughts?

---

<div class="post-metadata">

**Author:** ![spicecrm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.spicecrm.io/spicecrm/32/7_2.png) [@spicecrm](https://community.spicecrm.io/u/spicecrm)\
**Post date:** [March 7, 2017, 1:19pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/2 "2017-03-07T13:19:20Z")

</div>

for mobile you need to load a KREST extension. [http://www.spicecrm.io/downloads/](http://www.spicecrm.io/downloads/) lists the downloads and you can load and install teh mobile extension. I woudl assume that is missing.

---

<div class="post-metadata">

**Author:** ![dooferorg](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dooferorg](https://community.spicecrm.io/u/dooferorg)\
**Post date:** [March 8, 2017, 6:46pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/3 "2017-03-08T18:46:53Z")

</div>

No, like I said in my post, “I’ve downloaded KREST and the mobile module and installed them within the module loader.”

I’m not sure what else is needed?

---

<div class="post-metadata">

**Author:** ![spicecrm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.spicecrm.io/spicecrm/32/7_2.png) [@spicecrm](https://community.spicecrm.io/u/spicecrm)\
**Post date:** [March 10, 2017, 4:42pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/4 "2017-03-10T16:42:04Z")

</div>

can you send me the url via email to [info@spicecrm.io](mailto:info@spicecrm.io)

---

<div class="post-metadata">

**Author:** ![dooferorg](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dooferorg](https://community.spicecrm.io/u/dooferorg)\
**Post date:** [March 10, 2017, 4:55pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/5 "2017-03-10T16:55:46Z")

</div>

Sent you an email to that address

---

<div class="post-metadata">

**Author:** ![spicecrm](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.spicecrm.io/spicecrm/32/7_2.png) [@spicecrm](https://community.spicecrm.io/u/spicecrm)\
**Post date:** [March 10, 2017, 6:46pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/6 "2017-03-10T18:46:07Z")

</div>

your rewite rules are too strict. If no subpath is entered so calling just http:///KREST sysinfo needs to be returned. This should return what is sent when inly index.php is called. The mobile client is maing that call and that end up with no response. So please adopt your rewite rules accordingly.

---

<div class="post-metadata">

**Author:** ![dooferorg](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@dooferorg](https://community.spicecrm.io/u/dooferorg)\
**Post date:** [March 10, 2017, 7:30pm UTC](https://community.spicecrm.io/t/krest-api-on-nginx/85/7 "2017-03-10T19:30:18Z")

</div>

Ok… I tried doing that. I have the CRM url returning with the results of sysinfo even if the request is [https://site.crm.com/KREST/](https://site.crm.com/KREST/) …

Mobile App works 🙂

Here’s the updated rules, for completeness:

```
  autoindex off;
  location /KREST {
    if ($request_uri = "/KREST/") {
      rewrite ^/.* /KREST/sysinfo;
    }
    if ( !-e $request_filename ){
      rewrite ^(.*)$ /KREST/index.php break;
    }

    try_files index.php =404;
    allow all;

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 300;
    include fastcgi_params;
  }
```
