JupyterLab is an open-source web-based interactive development environment that extends the classic Jupyter Notebook experience, providing a more flexible and powerful interface for data science and scientific computing tasks. It supports various programming languages, with a strong focus on Python, and offers features like code editing, data visualization, and interactive output in a single, integrated workspace. JupyterLab allows users to create and manage notebooks, text editors, terminals, and other custom components in a tabbed layout, enhancing productivity and collaboration. On Ubuntu, it can be easily installed via package managers like apt or through Python’s package installer pip, making it an accessible tool for developers and researchers using this popular Linux distribution.

In this guide, you’ll learn how to install Jupyter on Ubuntu 24.04. You’ll install and secure Jupyter with password authentication. Then you’ll install Nginx and configure it as a reverse proxy.

Prerequisites

Before you start, make sure you have the following requirements:

  • An Ubuntu 24.04.
  • A non-root user with administrator privileges.
  • A domain name pointed to a server IP address (public or private domain).

Installing Dependencies

In this section, you’ll install dependencies for Jupyter, which includes Python, Pip, venv, and Node.js. Those packages are available by default on the Ubuntu repository, and you’ll install them through the APT package manager.

To start, run the command below to update your Ubuntu package index.

sudo apt update

Now install Python3 and Node.js through the Ubuntu repository with the following – Enter Y to confirm the installation:

sudo apt install python3-dev python3-pip python3-venv nodejs npm

<img alt="install dependencies" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/1-install-deps.png66990fc8f19d0.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="301" loading="lazy" src="data:image/svg xml,” width=”750″>

After the installation is complete, check the Python, Node.js, and Pip version with the following:

python3 -v

pip3 -v

node -v

You can see below Python 3.12, Node.js 18, and Pip 24 are installed.

<img alt="check version" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/2-check-py-pip-node.png66990fc928817.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="235" loading="lazy" src="data:image/svg xml,” width=”656″>

Installing Jupyter

After installing dependencies, you’ll install Jupyter through Pip in the Python virtual environment. You’ll run Jupyter as a non-root user, so make sure you’ve created it.

Log in to your user with the command below – The following example will be using user alice:

su – alice

Run the command below to create a new directory ~/Dev and move into it. Then, create a new Python venv virtual environment.

mkdir -p ~/Dev; cd ~/Dev

python3 -v venv venv

Now activate the venv virtual environment with the following command. Once activated, your shell will become like (venv) user@hostname.

source venv/bin/activate

Next, run the pip3 command below to install Jupyter through PyPi repository:

pip3 install jupyter

Below you can see the jupyter installation through the pip3 command:

<img alt="installing jupyter" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/3-setup-ven-install-jupyter.png66990fc95d860.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="427" loading="lazy" src="data:image/svg xml,” width=”750″>

After the process is finished, check the Jupyter version with the following command:

jupyter –version

You will see the version of each Jupyter component, such as jupyterlab, jupyter_server, jupyter_client, jupyter_core, and iPython.

Configuring Jupyter

In this section, you’ll configure two main components Jupyter, which are jupyter_server and jupyterlab. You’ll generate configuration and set up password authentication for both components. Then, you’ll run Jupyter through the command line.

First, run the jupyter command below to generate the jupyter_server configuration and password. Enter your password when prompted and repeat.

jupyter server –generate-config

jupyter server password

You can see below the jupyter_server configuration is generated to ~/.jupyter/jupyter_server_config.py, and the password file is written to ~/.jupyter/jupyter_server_config.json.

<img alt="generate server configuration and password" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/7-generate-server-config-password.png66990fc993b48.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="158" loading="lazy" src="data:image/svg xml,” width=”750″>

Check the jupyter_server configuration with the command below.

jupyter server –show-config

And you will see the similar output like the following:

<img alt="show server configuration" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/8-show-config-server.png66990fc9f1eb8.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="435" loading="lazy" src="data:image/svg xml,” width=”750″>

Next, run the jupyter command below to generate the jupyterlab configuration to ~/.jupyter/jupyter_lab_config.py. Then, check the jupyterlab configuration.

jupyter lab –generate-config

jupyter lab –show-config

In the following output, the default URL path for jupyterlab is /lab.

<img alt="geenrate jupyterlab configuration" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/9-generate-lab-config-show.png66990fca63199.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="474" loading="lazy" src="data:image/svg xml,” width=”750″>

Now run the jupyter command below to start jupyterlab from the command line. The jupyterlab should be running on port 8888 and the URL path lab.

jupyter lab –ip 0.0.0.0

<img alt="running jupyter from command line" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/10-jupyter-run-command.png66990fcaa7311.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="373" loading="lazy" src="data:image/svg xml,” width=”750″>

Visit http://server-ip:8888/lab to access your jupyterlab installation. You will see the following Jupyter dashboard.

<img alt="test jupyter" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/4-test.png66990fcad119a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="318" loading="lazy" src="data:image/svg xml,” width=”750″>

Now press Ctrl c and type yes to terminate the jupyterlab process.

Running JupyterLab as a service

In this guide, you’ll run Jupyter in the background as a service. So now you need to create a new systemd service file for Jupyter.

Create a new systemd service file /etc/systemd/system/jupyterlab.service with the following nano editor command.

sudo nano /etc/systemd/system/jupyterlab.service

Input the following configuration and make sure to change user alice with your username.

[Unit]
Description=JupyterLab Service

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/alice/Dev/venv/bin/jupyter lab --config=/home/alice/.jupyter/jupyter_lab_config.py
User=alice
Group=alice
WorkingDirectory=/home/alice/Dev
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Save the file and exit the editor when finished.

Now run the command below to reload the systemd manager and activate your new service file.

sudo systemctl daemon-reload

Next, start and enable the jupyterlab service with the command below.

sudo systemctl start jupyterlab

sudo systemctl enable jupyterlab

<img alt="jupyter systemd" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/11-jupyterlab-systemd.png66990fcb0c5c8.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="210" loading="lazy" src="data:image/svg xml,” width=”750″>

Lastly, run the command below to check the jupyterlab service status. You will see the jupyterlab service is running and enabled on your system.

sudo systemctl status jupyterlab

<img alt="check jupyter status" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/12-status.png66990fcb5ac30.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="216" loading="lazy" src="data:image/svg xml,” width=”750″>

Allowing remote access to Jupyter

Before setting up Nginx as a reverse proxy, you need to allow remote access on the jupyterlab. Now you’ll modify the file ~/.jupyter/jupyter_lab_config.py and enable remote access.

First, open the jupyterlab configuration ~/.jupyter/jupyter_lab_config.py with the following nano editor.

nano ~/.jupyter/jupyter_lab_config.py

Uncomment the c.ServerApp.allow_remote_access option and change it to True. This will enable remote access for jupyterlab.

c.ServerApp.allow_remote_access = True

Save and exit the file when finished.

Now run the command below to restart the jupyterlab service and apply your changes. After remote access is enabled in Jupyter, a new token for setting up a password will be generated.

sudo systemctl restart jupyterlab

Take a look at the bottom of the message, and copy the generated token for Jupyter.

<img alt="jupyter token" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/13-token.png66990fcb81700.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="137" loading="lazy" src="data:image/svg xml,” width=”750″>

Setting up Nginx as a reverse proxy

In this section, you’ll install and configure Nginx as a reverse proxy for your Jupyter installation. So make sure you’ve your domain name, whether public or private domain name.

Install the Nginx web server with the command below – Input Y to proceed with the installation.

sudo apt install nginx

<img alt="install nginx" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/14-install-nginx.png66990fcbc9e1a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="341" loading="lazy" src="data:image/svg xml,” width=”748″>

After the installation is complete, create a new Nginx server block configuration /etc/nginx/sites-available/jupyterlab with the following nano editor.

sudo nano /etc/nginx/sites-available/jupyterlab

Add the following configuration to the file and make sure to change the domain name within the server_name option.

server {
    listen 80;
    server_name lab.howtoforge.local;

    access_log /var/log/nginx/howtoforge.local.access.log;
    error_log /var/log/nginx/howtoforge.local.error.log;

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}

When done, save and exit the file.

Now run the command below to activate the jupyterlab server block and verify your Nginx syntax. If you have the correct configuration, you will get an output syntax is ok ... test is successful.

sudo ln -s /etc/nginx/sites-available/jupyterlab /etc/nginx/sites-enabled/

sudo nginx -t

Lastly, run the command below to restart Nginx and apply your new jupyterlab server block configuration. After the command is executed, your Jupyter is running under the Nginx reverse proxy.

sudo systemctl restart nginx

<img alt="setup nginx reverse proxy" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/15-nginx-reverse-proxy.png66990fcbe8b6d.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="169" loading="lazy" src="data:image/svg xml,” width=”750″>

Accessing Jupyter

If you’re using Linux or MacOS, edit the /etc/hosts file. For Windows users, edit the C:System32driversetchosts file as administrator.

Add your server IP address and the domain name Jupyter like the following:

192.168.5.65 lab.howtoforge.local

Save and exit the file.

Now open your web browser and visit your Jupyter domain name such as http://lab.howtoforge.local/. If your configuration is successful, you will see the Jupyter login page.

Scroll down to the bottom and paste the token for your Jupyter installation. Then, input the new password for Jupyter and click Log in and set new password.

<img alt="login token and change password" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/5-login-token.png66990fcc2b0b8.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="403" loading="lazy" src="data:image/svg xml,” width=”726″>

If successful, you’ll see the Jupyter dashboard like the following – And your password for Jupyter also changed.

<img alt="dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/07/echo/6-dashboard.png66990fcc64624.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="385" loading="lazy" src="data:image/svg xml,” width=”750″>

Conclusion

Congratulations! You’ve completed the installation of Jupyter on Ubuntu 24.04. You now have Jupyter running with Nginx as a reverse proxy and secured with password authentication. If you’re running Jupyter on a public server or VPS (Virtual Private Server), you must implement HTTPS on top of your Nginx reverse proxy. You can achieve that through Certbot and Letsencrypt.