# Jupyterlab nginx reverse proxy at subpath causing ServerApp 404 GET /api error

**URL:** <https://discourse.jupyter.org/t/jupyterlab-nginx-reverse-proxy-at-subpath-causing-serverapp-404-get-api-error/15243>\
**Category:** JupyterLab\
**Tags:** jupyterlab\
**Created:** [August 6, 2022, 12:32am UTC](https://discourse.jupyter.org/t/jupyterlab-nginx-reverse-proxy-at-subpath-causing-serverapp-404-get-api-error/15243 "2022-08-06T00:32:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajp619](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@ajp619](https://discourse.jupyter.org/u/ajp619)\
**Post date:** [August 6, 2022, 12:32am UTC](https://discourse.jupyter.org/t/jupyterlab-nginx-reverse-proxy-at-subpath-causing-serverapp-404-get-api-error/15243/1 "2022-08-06T00:32:13Z")

</div>

I’m trying to set up jupyter lab behind an nginx reverse proxy on the subpath /jlab

Here’s my minimal example:

docker-compose.yml

```auto
version: "3.7"
services:
  nginx:
    image: nginx:alpine
    volumes:
      - "./default.conf:/etc/nginx/conf.d/default.conf:ro"
    ports:
      - 8080:80
    links:
      - "jupyterlab"
  jupyterlab:
    image: jupyter/scipy-notebook
    container_name: jupyterlab
    volumes:
      - "./jupyter_server_config.py:/home/jovyan/.jupyter/jupyter_server_config.py:ro"

```

default.conf

```auto
server {
    listen 80;
    listen [::]:80;
    server_name localhost;

    location / {
        root /usr/share/nginx/html;
        index index.html index.htm;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location /jlab {
        proxy_pass http://jupyterlab:8888;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
    }
}

```

jupyter\_server\_config.py

```auto
c.ServerApp.allow_remote_access = True
c.ServerApp.allow_root = True
c.ServerApp.base_url = '/jlab'
c.ServerApp.ip = '*'
c.ServerApp.token = u''

```

This can be run with `docker compose up --build -d`  
jupyterlab can now be reached at `localhost:8080/jlab`  
Everything appears to be working. But if you look at the logs you get this repeated message:

```auto
jupyterlab | [W 2022-08-06 00:18:27.783 ServerApp] 404 GET /api (127.0.0.1) 1.04ms referer=None

```

The status of the container turns to `Up About a minute (unhealthy)`, so I’m guessing this will be a problem, but I’m not sure what the problem is or how to fix it.

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [August 7, 2022, 9:26pm UTC](https://discourse.jupyter.org/t/jupyterlab-nginx-reverse-proxy-at-subpath-causing-serverapp-404-get-api-error/15243/2 "2022-08-07T21:26:35Z")

</div>

This is due to the `HEALTHCHECK` in

> <https://github.com/jupyter/docker-stacks/blob/911ef4592b79f6601b20332dbfad602baf83c8b7/base-notebook/Dockerfile#L159-L164>

I think this `HEALTHCHECK` is worth mentioning in the docs as it’s come up a few times before. The docs are [https://jupyter-docker-stacks.readthedocs.io/](https://jupyter-docker-stacks.readthedocs.io/) and the repo is [GitHub - jupyter/docker-stacks: Ready-to-run Docker images containing Jupyter applications](https://github.com/jupyter/docker-stacks/) if you want to open an issue or a PR!

---

<div class="post-metadata">

**Author:** ![ajp619](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@ajp619](https://discourse.jupyter.org/u/ajp619)\
**Post date:** [August 8, 2022, 3:08pm UTC](https://discourse.jupyter.org/t/jupyterlab-nginx-reverse-proxy-at-subpath-causing-serverapp-404-get-api-error/15243/3 "2022-08-08T15:08:53Z")

</div>

Just to close the loop, adding the environment variable to the jupyterlab section of the docker-compose file fixes the issue identified by @manics:

```auto
  jupyterlab:
    image: jupyter/scipy-notebook
    container_name: jupyterlab
    volumes:
      - "./jupyter_server_config.py:/home/jovyan/.jupyter/jupyter_server_config.py:ro"
    environment:
      - "JUPYTERHUB_SERVICE_PREFIX=/jlab/"

```

🥳
