Jupyter Web App
We are going to install jupyter lab on ubuntu and expose it to the web using NGINX reverse proxy. Jupyter lab web access helps in running your codes on server. Premade codeblocks can be used to generate desired output, thus automating sundane tasks. The interface allso provides access to code files, output files. External files can also be uploaded for processing and storage.
Create Virtual Python Environment
First we creaete a pythion virtual environment in Ubuntu. For the same you need to have python installed. if not use blow command to install python
Now lets create a directory Documents in the userdirectory (home/user) using - mkdir Documents
. Change to the directory cd Documents
and run below command to create a virtual environment.
The virtual environment will be created in folder /Documents/venv
To activatet the virtual environment
the command prompt will change with a (venv) in the beginning. To deactivatet the virtual environment
Installing Jupyter Lab
Now we install Jupyter Lab using pip
To launch juypter lab use below command
This will launch the jupyter lab on the local host with port 8888 This instance is not secure as it can be accessed without a password on the browser. To add a password for login use below command
Enter the new password when asked. Jupyter will create a jupyter_server_config.json file in user/username/.jupyter
folder and srtore the password in hashed format.
Setting up NGINX reverse proxy
To expose the sever to a custom domain we need to add NGINX reverse proxy. More details are available at -
The server config file will look like this - replace example.com
with your own domain name
Ensure that your DNS provider has the A record for domain example.com
, pointing at the public ip of server hosting Jupyter Server. For newer version of Jupyter Lab we need one more step to allow request coming from public adress of example.com
We need to launch the Jupyter Lab instance with the option --ServerApp.allow_remote_access=true
As we are not going to use a local browser for accessing the server we can launch Jupyter Lab using below command. Note the disown
argument helps to release the command prompt once the server is launched.
Creating Launch Script
To avoid long step of activating the python virtual environment and then lauching the jupyter lab using the above command, we create a bash script.
Copy the below content into the script file. Replace your username
and file path where necessary
To launch script, navigate to the script directory and run
To find and kill a running instance
This will show the process id
of Jupyter Lab
Last updated