Deployment Overview of JupyterLab on Server¶
Prerequisites and Basic Requirements¶
The deployment of JupyterLab on the host server requires the following system prerequisites and configurations:
-
Operating System: Ubuntu Linux.
-
Privileges: Root (superuser) access is required for service management and configuration changes.
-
Domain: The deployment is configured for the
hostkey.indomain. -
Network Ports:
-
Port
443(HTTPS) for external secure access via the reverse proxy. -
Port
8888(TCP) for the internal JupyterLab application service.
-
FQDN of the Final Panel¶
The final access point for the application is resolved via the Hostkey domain using the specific prefix and server identifier: labServer ID'.hostkey.in:443 (Note: Replace "Server ID" with the actual server identifier specific to your instance to form the complete FQDN, e.g., lab123.hostkey.in.)
File and Directory Structure¶
The application and its supporting services utilize the following directory structure on the host system:
-
Data Directory:
/opt/dataserves as the primary storage location for JupyterLab notebooks and virtual environments.-
Virtual Environment:
/opt/data/jupyter -
Jupyter Share Directory:
/opt/data/jupyter/share/jupyter
-
-
Nginx Configuration:
/root/nginxcontains the Docker Compose configuration for the reverse proxy. -
Systemd Service:
/usr/lib/systemd/system/jupyterlab.servicedefines the service management unit. -
Certificates and Secrets: Nginx mounts certificates to
/etc/letsencrypt(via Docker volumenginx_secrets) and user configurations to/etc/nginx/user_conf.d. -
System Home: The
/homedirectory is mounted into the Nginx container.
Application Installation Process¶
The JupyterLab application is installed directly onto the Ubuntu host using package managers and a Python virtual environment:
-
System Packages: Core dependencies including
python3,python3-pip,jupyter, andpython3-virtualenvare installed via theaptpackage manager. -
User Creation: A dedicated system user
jupyter(UID 2841) and groupjupyter(GID 2841) are created for execution context. -
Virtual Environment: A Python virtual environment is initialized at
/opt/data/jupyter. -
Package Installation: The following Python packages are installed within the virtual environment:
-
jupyterlab -
jupyter-core -
voila -
jupyter-server
-
-
Configuration Generation:
-
The Jupyter Lab configuration file is generated using the command
/opt/data/jupyter/bin/jupyter lab --generate-config. -
A password for access is generated using
/opt/data/jupyter/bin/jupyter lab password.
-
-
Service Setup: A
systemdservice file is deployed to manage the application lifecycle.
Access Rights and Security¶
Security and access controls are implemented through the following mechanisms:
-
Firewall: Access is restricted to port
443(HTTPS) for external traffic. Internal traffic uses port8888. -
User Context: The JupyterLab service runs as the
rootuser and group, as defined in thejupyterlab.serviceunit file (User=root,Group=root). -
Network Isolation: The Nginx reverse proxy runs in
hostnetwork mode (network_mode: host), directly accessing the host network stack. -
SSL/TLS: Secure connections are handled by the
nginx-certbotcontainer, which manages SSL certificates via Let's Encrypt.
Docker Containers and Their Deployment¶
A reverse proxy container is deployed using Docker Compose to handle SSL termination and traffic routing.
Deployment Location: /root/nginx Management Command:
Container Details:
-
Image:
jonasal/nginx-certbot:latest -
Restart Policy:
unless-stopped -
Volumes:
-
nginx_secrets(external) mapped to/etc/letsencrypt. -
Host path
/data/nginx/user_conf.dmapped to/etc/nginx/user_conf.d. -
Host path
/homemapped to/homeinside the container.
-
-
Environment:
-
CERTBOT_EMAIL: Set to[email protected]. -
Configuration loaded from
/data/nginx/nginx-certbot.env.
-
Proxy Servers¶
Traffic is routed through an Nginx reverse proxy container that provides SSL termination and custom domain support:
-
Software: Nginx with Certbot integration.
-
Image Source:
jonasal/nginx-certbot. -
Configuration: The proxy configuration is generated and stored in
/root/nginx/compose.yml. -
SSL Management: Automatic certificate generation and renewal are handled by the container's built-in Certbot functionality.
-
Routing: The proxy forwards requests from port
443to the internal JupyterLab service on port8888.
Permission Settings¶
File and directory permissions are configured as follows:
-
/opt/data: Owned byjupyter:jupyterwith mode0777(read, write, execute for all). -
/opt/data/jupyter: Owned byjupyter:jupyterwith mode0755(read, execute for others). -
/root/nginx: Owned byroot:rootwith mode0644. -
Configuration Files: The
jupyterlab.serviceandcompose.ymlfiles are owned byroot.
Location of Configuration Files and Data¶
-
JupyterLab Config:
/root/.jupyter/jupyter_lab_config.pyand/root/.jupyter/jupyter_server_config.json. -
Nginx Docker Compose:
/root/nginx/compose.yml. -
Nginx Environment:
/data/nginx/nginx-certbot.env. -
Service Definition:
/usr/lib/systemd/system/jupyterlab.service. -
Notebook Data:
/opt/data/jupyter/share/jupyter.
Available Ports for Connection¶
The system exposes the following ports for network communication:
-
Port 443: HTTPS (External access via Nginx proxy).
-
Port 8888: TCP (Internal JupyterLab service, not directly exposed to the public internet).
Starting, Stopping, and Updating¶
The JupyterLab application is managed via the systemd service manager.
Start the Service:
Stop the Service:
Restart the Service:
Enable on Boot:
Status Check:
Reload Daemon Configuration:
To update the Nginx proxy configuration, modify the file at /root/nginx/compose.yml and run docker compose up -d within the /root/nginx directory.