Jupyter notebook Jupyter笔记本服务器:限制对选定IP的访问

Jupyter notebook Jupyter笔记本服务器:限制对选定IP的访问,jupyter-notebook,jupyter,Jupyter Notebook,Jupyter,我正在我的局域网上设置一个jupyter笔记本服务器,我想将其限制为网络中的几个IP 我遵循了配置设置:现在至少有了密码安全性。 但我想让它更安全,并且只限于我网络中选定的IP地址 有关主机的详细信息:Windows 10和Anaconda Myjupyter\u notebook\u config.py: # Set options for certfile, ip, password, and toggle off # browser auto-opening c.NotebookApp.c

我正在我的局域网上设置一个jupyter笔记本服务器,我想将其限制为网络中的几个IP

我遵循了配置设置:现在至少有了密码安全性。 但我想让它更安全,并且只限于我网络中选定的IP地址

有关主机的详细信息:Windows 10和Anaconda

My
jupyter\u notebook\u config.py

# Set options for certfile, ip, password, and toggle off
# browser auto-opening
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/fullchain.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/privkey.pem'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
#c.NotebookApp.allow_origin = ''
c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
c.NotebookApp.open_browser = False

# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 9999
#设置证书文件、ip、密码和关闭开关的选项
#浏览器自动打开
c、 NotebookApp.certfile=u'/absolute/path/to/your/certificate/fullchain.pem'
c、 NotebookApp.keyfile=u'/absolute/path/to/your/certificate/privkey.pem'
#将ip设置为“*”以绑定公共服务器的所有接口(ip)
c、 NotebookApp.ip='*'
#c、 NotebookApp.allow_origin=''
c、 NotebookApp.password=u'sha1:bcd259ccf…'
c、 NotebookApp.open\u browser=False
#最好为服务器访问设置一个已知的固定端口
c、 NotebookApp.port=9999
我本想在
c.NotebookApp.ip
中设置ip列表,但没有成功。
你能帮我一下吗?

我不知道如何通过jupyter配置来实现这一点,但我认为使用反向代理服务器(如nginx)会更好,并且可以提供更多的安全功能

这里有一个例子
nginx.conf

worker_processes 1;

events { worker_connections 1024; }

http {

    sendfile on;

    upstream ml {
        server jupyterhub:8000;
    }

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen 8080;
        allow  192.168.1.1/24;


        location / {
            proxy_pass http://ml;

            proxy_redirect   off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            # websocket headers
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }
    }

}
您可以在这里配置在任何端口
8080
上侦听,甚至可以使用SSL之类的东西

您可以在此处找到更多参考资料:

您可以使用像nginx这样的反向代理服务器。这将使实现此功能和其他安全功能更加容易。谢谢@Yuvraj。这有点超出我的范围,但如果这是唯一的解决方案,我会深入研究。添加了一个答案,并提供了更多细节,以帮助您解决问题。