【问题标题】:Running jupyter notebook on cloud 9在云 9 上运行 jupyter notebook
【发布时间】:2022-08-07 02:56:02
【问题描述】:

我在我的 AWS 账户上设置了一个 cloud 9 实例。我使用诗歌作为我的包管理器并安装了 jupyter notebook。

当我运行命令poetry run jupyter notebook 时,它会像往常一样运行,但是当我按下链接时,他们说无法访问该站点。

我注意到的一些事情是,在某些 AWS 文档中提到了使用端口 8080,我已经尝试过,但它不起作用。

我还看到了一些关于 http 与 https 的信息,所以它会不会因为链接不是 https 而不会显示?

不管如何打开在云 9 实例上运行的笔记本的任何帮助都会非常有帮助,谢谢

    标签: amazon-web-services jupyter-notebook python-poetry aws-cloud9


    【解决方案1】:

    对于 HTTP:

    jupyter notebook --generate-config
    echo "conf = get_config()" >> ~/.jupyter/jupyter_notebook_config.py
    echo "conf.NotebookApp.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py
    echo "conf.NotebookApp.password = u'YOUR PASSWORD HASH'" >> ~/.jupyter/jupyter_notebook_config.py
    echo "conf.NotebookApp.port = 8888" >> ~/.jupyter/jupyter_notebook_config.py
    jupyter notebook
    

    然后点击http://ip-address:8888


    对于 HTTPS:

    export DNS=$(curl -s http://169.254.169.254/latest/meta-data/public-hostname)
    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/ec2-user/mykey.key -out /home/ec2-user/mycert.pem -subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=$DNS"
    echo "conf = get_config()" >> ~/.jupyter/jupyter_notebook_config.py
     
    echo "conf.NotebookApp.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py
    echo "conf.NotebookApp.password = u'YOUR PASSWORD HASH'" >> ~/.jupyter/jupyter_notebook_config.py
    echo "conf.NotebookApp.port = 8888" >> ~/.jupyter/jupyter_notebook_config.py
    jupyter notebook --certfile=/home/ec2-user/mycert.pem --keyfile /home/ec2-user/mykey.key
    

    然后点击https://ip-address:8888


    无论哪种情况,请确保在 EC2 安全组和网络 ACL 中允许端口 8888

    【讨论】:

    • 您好,感谢详细解答。我尝试过,但是在单击“单击继续”按钮后,我得到 403:Forbidden。有什么想法吗?
    • @HashBr0wn 您是否已将 EC2 实例的安全组配置为允许从您的 IP 地址访问端口 8888?
    • @HashBr0wn 您是否设法让事情正常进行?
    • @HashBr0wn 我的解决方案中有一个小问题,我现在已经修复了
    • @HashBr0wn 实际上,事实证明,通过设置 nginx 反向代理可能会有更简单的解决方案。我将发布另一个答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 2017-10-29
    • 2018-11-07
    • 2018-12-02
    相关资源
    最近更新 更多