はじめに

Omnibus版のGitLabを稼働させているサーバから,LAN内の別のマシンで稼働しているJupyterに接続したかったので,その時の記録です.

環境

    • ルータ

 

    • IP:192.168.0.1

 

    • サーバ1(GitLab用)

 

    • OS: CentOS 7.5

 

    • IP: 192.168.0.2

 

    • サーバ2(Jupyter用)

 

    • OS: Ubuntu 18.04 LTS

 

    • IP: 192.168.0.3

 

    • JupyterはLAN内からパスワード認証で接続できるようになっています

 

    ( https://qiita.com/tdrk/items/e6c293021cbcb0e96cd2 )

Jupyterの設定の変更(サーバ2)

~/.jupyter/jupyter_notebook_config.pyの各項目を以下のように編集します.

c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.base_url = '/jupyter/'
c.NotebookApp.base_project_url = '/jupyter/'
c.NotebookApp.webapp_settings = {'static_url_prefix':'/jupyter/static/'}

jupyter notebookをバックグラウンドで起動させておきます.

$ jupyter notebook &

nginxの設定の変更(サーバ1)

/var/opt/gitlab/nginx/confに設定ファイルjupyter.confを作成します.

location /jupyter {
    proxy_pass http://192.168.0.3:8888;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
}

GitLabのnginxは,/etc/gitlab/gitlab.rbの内容から設定ファイルを自動生成するので,先程作成した設定ファイルを読み込むよう次の1行を追加します.

nginx['custom_gitlab_server_config'] = "include /var/opt/gitlab/nginx/conf/jupyter.conf;"

これで,LAN内からhttp://192.168.0.2:8888/jupyterに接続すると,jupyter notebookが操作できると思います.

参考URL


http://www.albertauyeung.com/post/setup-jupyter-nginx-supervisor/

广告
将在 10 秒后关闭
bannerAds