我的计算机运行jupyter notebook
并具有以下设置:
c.NotebookApp.password = u'sha1:'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 9999
c.NotebookApp.base_url = '/notebook/'
c.NotebookApp.allow_origin = '*'
c.NotebookApp.trust_xheaders = True
和nginx
conf设置如下:
server {
listen 80;
server_name example.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 default_server ssl;
server_name example.domain.com;
keepalive_timeout 70;
ssl_certificate chained.crt;
ssl_certificate_key .key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://localhost:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /notebook {
proxy_pass http://localhost:9999/notebook;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /notebook/nbextensions {
proxy_pass http://localhost:9999/notebook/nbextensions/;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
# to configure the kernel for python
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
我的想法是我在8081上运行了不同的服务,我希望能够访问example.domain.com/notebook上的笔记本。
直接在localhost:9999上的本地机器上使用笔记本电脑绝对正常。但是当我尝试从远程地址访问它时,一切正常,除了它无法保存笔记本。
这是(有些编辑过的)错误消息:
[W 11:02:37.568 NotebookApp] Unexpected error while saving file: notebook.ipynb [|
Errno 13] Permission denied: '/.ipynb_checkpoints/notebook-checkpoint.ipynb'|
[E 11:02:37.569 NotebookApp] { |
"Content-Type": "application/json", |
"Connection": "upgrade", |
"Content-Length": "4600", |
"X-Real_ip": "xxx.xxx.xxx.xxx", |
"X-Xsrftoken": "2|f9bfac9e|92b9bb14e19945238a1b3445e08c86f7|1484213065", |
"Cookie": "_xsrf=2|f9bfac9e|92b9bb14e19945238a1b3445e08c86f7|1484213065; username-example-domain-com=\"2|1:0|10:1484213084|27:us|
ername-example-domain-com|44:Mjk3MDYzYWU2M2FkNGVmNDlkZWFiMGY4NjU5NDZlOTU=|8b4ceb3a6ebd248a84beeffd867815c7269a98f2ba1a360562034ca21c95|
ae9a\"", |
"Accept-Encoding": "gzip, deflate, br", |
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0", |
"X-Nginx-Proxy": "true", |
"Referer": "https://example.domain.com/notebook/notebooks/notebook.ipynb", |
"Accept-Language": "en-US,en;q=0.5", |
"Accept": "application/json, text/javascript, */*; q=0.01", |
"Host": "example.domain.com", |
"X-Forwarded-For": "157.181.241.173", |
"X-Requested-With": "XMLHttpRequest" |
}
[E 11:02:37.569 NotebookApp] 500 PUT /notebook/api/contents/notebook.ipynb (127.0
.0.1) 169.93ms referer=https://example.domain.com/notebook/notebooks/notebook.ipynb
如果我从localhost执行此操作,则完全相同。我已经尝试了我在互联网上找到的nginx confs的各种其他设置,但找不到任何设置。我在我自己的用户下运行笔记本,但我的用户具有对所述文件夹(以及笔记本的写入权限,因为在localhost上运行它不会显示此问题)。据我所知,nginx不应该更改正在运行的用户与它无关,它只是代理对jupyter笔记本服务器的调用。所以我不知道可能是什么问题。