# 404 error for just /api calls. Nginx as proxy

**URL:** https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958
**Category:** Kibana
**Created:** [August 27, 2019, 1:54pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958 "2019-08-27T13:54:41Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [August 27, 2019, 1:54pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/1 "2019-08-27T13:54:41Z")

</div>

I'm running Kibana 7.3 behind an Nginx proxy (in Kubernetes) and most things work but the /api calls don't seem to respect the basePath configuration. I set the basePath value and most calls prepend that and work, but all the /api calls don't prepend the basePath and therefore get 404 errors. Anyone else get this problem? Any solutions?

---

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [August 27, 2019, 3:46pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/2 "2019-08-27T15:46:16Z")

</div>

I worked around this issue by adding a location /api section that then adds the api:

location /api {  
rewrite ^/api/(/.\*)$ /api/$1 permanent;  
}

The plugin should just prepend my basepath /mybasepath/api and then i wouldn't have had to do this.

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [August 27, 2019, 9:37pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/3 "2019-08-27T21:37:00Z")

</div>

Hope are you configuring the base path? The`/api` endpoint should 100% respect the basePath

---

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [August 28, 2019, 1:08pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/4 "2019-08-28T13:08:05Z")

</div>

Yea the basePath is definitely used because all of Kibana works except for the /api calls.

---

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [August 28, 2019, 1:11pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/5 "2019-08-28T13:11:53Z")

</div>

I don't see prepending basePath here:

> <https://github.com/elastic/kibana/blob/4025d1dfbb60a323c3a423fdb9e79674987dc906/src/legacy/core_plugins/console/public/src/kb.js>

```
 $.ajax({
  url:
    '../api/console/api_server?sense_version=' +
    encodeURIComponent('@@SENSE_VERSION') +
    '&apis=' +
    encodeURIComponent(api),

```

dataType: 'json', // disable automatic guessing

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [August 28, 2019, 2:46pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/6 "2019-08-28T14:46:09Z")

</div>

Sorry, I meant to ask "How are you configuring the base path?" Typing is hard...

I should add that the bit of code you reference contains a relative url in order to support the base path.

---

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [August 28, 2019, 3:15pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/8 "2019-08-28T15:15:31Z")

</div>

This is running in Kubernetes using a nginx ingress controller proxy and I see the nginx.conf has /api location block for something else. But I don't understand why that would affect this case. If /mybasepath/api is then sent to Kibana /api it shouldn't matter that something else calls /api that goes to another application.

---

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [August 28, 2019, 4:03pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/9 "2019-08-28T16:03:52Z")

</div>

Does anyone know if the basepath is passed over in the header. What if the proxy somehow removes the basepath?

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [September 1, 2019, 3:58am UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/10 "2019-09-01T03:58:04Z")

</div>

> Does anyone know if the basepath is passed over in the header. What if the proxy somehow removes the basepath?

The basepath is set via `kibana.yml` or arguments passed when the process is started - [Configure Kibana | Kibana Guide [8.11] | Elastic](https://www.elastic.co/guide/en/kibana/current/settings.html)

Can you connect to kibana without the proxy to see if you have the same problem?

---

<div class="post-metadata">

### Author: ![data\_smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/data_smith/32/124122_2.png) [@data\_smith](https://discuss.elastic.co/u/data_smith)
#### Post date: [September 3, 2019, 12:47pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/11 "2019-09-03T12:47:08Z")

</div>

Yes Kibana works without the proxy and it works with the proxy with the exception of the api calls. It only visibly affects things if I want to use the monitoring plugin otherwide for what I need it works. I do have the basePath set in kibana.yml by the way. No one else seems to run into this problem so maybe it's something weird with my setup with Kubernetes ingress controller.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 1, 2019, 12:47pm UTC](https://discuss.elastic.co/t/404-error-for-just-api-calls-nginx-as-proxy/196958/12 "2019-10-01T12:47:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
