Deployment Overview of Jupyter Notebook on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Ubuntu (recommended).
-
Privileges: Root or sudo access is required for package installation and service management.
-
Python Environment: Python 3 and
pipare required for the virtual environment setup. -
Docker: Docker and Docker Compose must be installed to run the Nginx reverse proxy with SSL support.
FQDN of the final panel on the hostkey.in domain¶
The application is accessible via a specific subdomain based on the server ID.
| Parameter | Value |
|---|---|
| Prefix | notebook |
| Domain | hostkey.in |
| Full template | notebook{Server_ID_from_Invapi}.hostkey.in |
File and Directory Structure¶
The following directories are used for application data, configurations, and proxy management:
-
/opt/data: Main data directory for Jupyter Notebook. -
/opt/data/jupyter: Python virtual environment and notebook files. -
/root/.jupyter/: Jupyter configuration files. -
/root/nginx/: Nginx Docker Compose configuration and deployment files. -
/data/nginx/user_conf.d/: Custom Nginx configuration files for the proxy. -
/data/nginx/nginx-certbot.env: Environment variables for the Nginx container.
Application installation process¶
The installation follows a two-stage process involving system package installation and Docker deployment:
-
System Dependencies: The installer installs
python3,python3-pip,jupyter, andpython3-virtualenvvia theaptpackage manager. -
User Setup: A dedicated system user named
jupyter(UID 2841) is created to manage the application environment. -
Virtual Environment: A Python virtual environment is initialized in
/opt/data/jupyter. -
Application Installation: The following packages are installed within the virtual environment via
pip: -
notebook -
voila -
virtualenv -
jupyter-server -
Configuration Generation: Jupyter configuration files are generated, and security settings (such as CORS origin) are applied to
/root/.jupyter/jupyter_notebook_config.py. -
Service Configuration: A systemd service unit is created at
/usr/lib/systemd/system/jupyter-notebook.serviceto manage the application process. -
Proxy Deployment: A Docker container running
jonasal/nginx-certbot:latestis deployed via Docker Compose in/root/nginx/to handle SSL termination and reverse proxying.
Access Rights and Security¶
-
User Isolation: The Jupyter processes run under the
jupyteruser for security, while the systemd service manages the execution from a controlled environment. -
Firewall: The application is intended to be accessed via HTTPS (Port 443).
-
Authentication: A password is generated during installation to secure the Jupyter Notebook interface.
Databases¶
No external database management system is required for this deployment, as it utilizes local file storage for notebook data and configuration.
Docker Containers and Their Deployment¶
The deployment includes one primary application container managed via Docker Compose:
Nginx Proxy Container
-
Image:
jonasal/nginx-certbot:latest -
Ports: Uses
hostnetwork mode to bind directly to host ports. -
Volumes:
-
nginx_secrets:/etc/letsencrypt: For SSL certificate storage. -
/data/nginx/user_conf.d:/etc/nginx/user_conf.d: For custom Nginx site configurations. -
/home:/home: Access to host home directories. -
Environment Variables:
CERTBOT_EMAILis set for Let's Encrypt communications. -
Restart Policy:
unless-stopped.
Custom Scripts and Additional Setup¶
The installation performs several automated setup actions:
-
Password Generation: Automatically sets a Jupyter Notebook password using the provided credentials.
-
Systemd Integration: Configures the application to start automatically on system boot via
systemd. -
Environment Configuration: Modifies Jupyter configuration files to allow cross-origin requests (
c.ServerApp.allow_origin = '*').
Application Update Instructions¶
To update the main Jupyter Notebook application, follow these steps:
-
If updating the proxy layer, navigate to
/root/nginxand run: -
For the core Jupyter application, ensure the virtual environment is updated via
pipwithin the/opt/data/jupyterdirectory.
Location of configuration files and data¶
-
Jupyter Config:
/root/.jupyter/jupyter_notebook_config.pyand/root/.jupyter/jupyter_server_config.json. -
Application Data:
/opt/data/jupyter/share/jupyter. -
Nginx Configuration:
/data/nginx/user_conf.d/.
Available ports for connection¶
-
HTTPS:
443(via Nginx Proxy). -
Internal Jupyter Port:
8888(accessible via the proxy).
Starting and Stopping the application¶
The application is managed as a system service:
-
Start Jupyter Notebook:
-
Stop Jupyter Notebook:
-
Enable on Boot:
Proxy Servers¶
The application uses an Nginx container with Certbot integration to provide SSL/TLS encryption. The proxy handles incoming traffic on port 443 and forwards it to the Jupyter Notebook service running locally. Custom domain routing is managed through configuration files located in /data/nginx/user_conf.d/.