Jupyter Labs

Jupyter labs
Author

Benedict Thekkel

from jupyter_server.auth import passwd
print(passwd())
Enter password:  ········
Verify password:  ········
argon2:$argon2id$v=19$m=10240,t=10,p=8$75Q7uCcjzIK2HqrZKSvo7g$y8eYdSDFeAEAZW0S74A/q/+nSMq3CAIl4hSBpdgkSVg

jupyter_notebook_config.py

c = get_config()  # noqa

#------------------------------------------------------------------------------
# Application Configuration
#------------------------------------------------------------------------------
## Logging configuration
c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
c.Application.log_level = 'INFO'

#------------------------------------------------------------------------------
# Jupyter Server Configuration
#------------------------------------------------------------------------------
## General settings
c.ServerApp.ip = '0.0.0.0'  # Allow connections from all network interfaces
c.ServerApp.port = 8888  # Port to serve Jupyter Lab
c.ServerApp.open_browser = False  # Do not open a browser on server start
c.ServerApp.allow_root = True  # Allow running as root (if needed)
c.ServerApp.base_url = '/'  # Base URL for Jupyter Lab
c.ServerApp.trust_xheaders = True  # Support reverse proxies (e.g., Nginx)

## Security settings
c.ServerApp.token = ''  # Disable token-based authentication
c.ServerApp.password = 'sha1:<your-secure-password-hash>'  # Set hashed password
c.ServerApp.password_required = True  # Require a password
c.ServerApp.disable_check_xsrf = False  # Prevent cross-site request forgery

## SSL Configuration (optional)
# c.ServerApp.certfile = '/path/to/ssl/certfile.pem'
# c.ServerApp.keyfile = '/path/to/ssl/keyfile.pem'

## Performance tuning
c.ServerApp.max_body_size = 536870912  # Set maximum client request body size
c.ServerApp.max_buffer_size = 536870912  # Set buffer size

## Logging to a file
c.Application.logging_config = {
    "version": 1,
    "handlers": {
        "file": {
            "class": "logging.FileHandler",
            "filename": "/home/<your-username>/Documents/jupyter_lab.log",
            "level": "INFO",
            "formatter": "default",
        },
    },
    "formatters": {
        "default": {
            "format": "[%(name)s]%(highlevel)s %(message)s",
            "datefmt": "%Y-%m-%d %H:%M:%S",
        },
    },
    "root": {
        "handlers": ["file"],
        "level": "INFO",
    },
}

#------------------------------------------------------------------------------
# Jupyter Lab Configuration
#------------------------------------------------------------------------------
## Default application and URL
c.ServerApp.default_url = '/lab'  # Redirect to Jupyter Lab on start

## Work directory
c.ServerApp.root_dir = '/home/<your-username>/Documents/Knowledge'  # Set root directory for Jupyter Lab

## Terminals
c.ServerApp.terminals_enabled = True  # Enable terminal in Jupyter Lab

#------------------------------------------------------------------------------
# Extension Configuration
#------------------------------------------------------------------------------
## Example: Enabling an extension
# c.ServerApp.jpserver_extensions = {
#     "jupyterlab_code_formatter": True,
# }

#------------------------------------------------------------------------------
# Advanced Configuration
#------------------------------------------------------------------------------
## Kernel Management
c.ServerApp.kernel_manager_class = 'jupyter_server.services.kernels.kernelmanager.MappingKernelManager'
c.ServerApp.kernel_spec_manager_class = 'jupyter_client.kernelspec.KernelSpecManager'

## Federated extensions (optional)
# c.LabServerApp.extra_labextensions_path = ['/path/to/extensions']
# c.LabServerApp.labextensions_path = ['/path/to/extensions']

jupyter_server_config.json

{
  "ServerApp": {
    "password": "argon2:$argon2id$v=19$m=10240,t=10,p=8$75Q7uCcjzIK2HqrZKSvo7g$y8eYdSDFeAEAZW0S74A/q/+nSMq3CAIl4hSBpdgkSVg"
  }
}
Back to top