jupyter/notebook#1311 https://github.com/openfisca/jupyter/blob/master/config/nginx_configuration/jupyterhub.nginx.conf https://programming.vip/docs/running-jupyter-jupyterhub-jupyterlab-as-a-system-service.html https://janakiev.com/blog/jupyter-systemd/
jupyter lab --generate-config
Writing default config to: /root/.jupyter/jupyter_lab_config.py
c.ServerApp.allow_remote_access = True
c.ServerApp.allow_root = True
c.ServerApp.open_browser = False
c.ServerApp.allow_origin = '*'
c.ServerApp.password # from jupyter_server.auth import passwd; passwd()
c.ServerApp.root_dir = '/root'
root@vultr:/etc/systemd/system# cat jupyter.service
[Unit]
Description=Jupyter Lab
After=syslog.target network.target
[Service]
User=root
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
WorkDirectory=/root/
ExecStart=jupyter lab
[Install]
WantedBy=multi-user.target
upstream notebook {
server localhost:8888;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
#server_name www.yourdomain.com;
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/sites-available/server.crt; #server公钥证书
ssl_certificate_key /etc/nginx/sites-available/server.key; #server私钥
ssl_client_certificate /etc/nginx/sites-available/client.crt; #客户端公钥证书
ssl_verify_client on; #开启客户端证书验证
location / {
proxy_pass http://notebook;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Origin "";
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
location ~* /(api/kernels/[^/]+/(channels|iopub|shell|stdin)|terminals/websocket)/? {
proxy_pass http://notebook;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Origin "";
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}