Access Jupyter Lab running on VPS from internet via browser

On a VPS I ran a dockerized Jupyter Lab that itself driven from project freqtrade. It is the docker-compose and Dockerfile : docker-compose.yml :

version: '3'
      context: .
      dockerfile: docker/Dockerfile.jupyter
    restart: unless-stopped
    container_name: ft_jupyterlab
      - ""
      - "./user_data:/freqtrade/user_data"
    # Default command used when running `docker compose up`
    command: >
      jupyter lab --port=8888 --ip --allow-root --NotebookApp.token=''

Dockerfile.jupyter :

FROM freqtradeorg/freqtrade:develop_plot

# Pin prompt-toolkit to avoid questionary version conflict
RUN pip install jupyterlab "prompt-toolkit<=3.0.36" jupyter-client --user --no-cache-dir

# Empty the ENTRYPOINT to allow all commands

I want to access the Jupyter Lab from the internet via browser. So, I used Nginx as below:

server {
    listen 7000;
    server_name _;

    location / {
        proxy_pass http://localhost:8888;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

Suppose that is pointed to <vps_ip> . By navigating to from another machine, just the title of “JupyterLab” shown. No any contents rendered in browser.

Also it is log:

[I 2024-02-06 06:18:07.626 ServerApp] 302 GET / (@ 0.63ms

With your config, JupyterLab should be served at Starting jupyter-lab without any token is not recommended. As you are opening the nginx for internet, anyone will be able to access your Jupyterlab server. Use a token in jupyterlab command and then you will be prompted to use that token while access JupyterLab.

If it does not work, please post logs of JupyterLab. You should be able to access them using docker logs ft_jupyterlab on your VPS.

I found the problem. In docker-compose file in sections port mapping, must be removed.
- “8888:8888”

so, the JupyterLab is accessible through http://<vps_ip>:8888 (without Nginx reverse proxy), but still the way using Nginx (http://<vps_ip>:7000) doesn’t work. The log is mentioned at the end of my main post.