How to set up jupyter notebook in your server or VPS remotely with subdomain and cloudflare?

 How to set up jupyter notebook in server?


# new jupyterlab does not allow cloudflare subdomain access no matter how you try, so we use old
pip install jupyterlab==3.2.8


# set up password
jupyter lab password


# then modify a file 'vim ~/.jupyter/jupyter_server_config.json' to allow subdomain
```
{
  "ServerApp": {
    "password": "JkZ12Ij",
    "allow_origin": "*",
    "allow_remote_access": true
  }
}
~      
```



# new jupyterlab does not have 'jupyter lab' command, so you can only use 'jupyter server'. But it does not allow subdomain access.
jupyter lab --ip 127.0.0.1 --port 9998 --allow-root /root/



# I use traefik to do proxy from subdomain to localhost, but use nginx will be easyer since nginx has many tutorial online



# auto start, with "crontab -e"
@reboot /usr/local/bin/jupyter lab --ip 127.0.0.1 --port 19998 --allow-root /root/