解决Jupyter无法保存(413: Request Entity Too Large )

narcissuskid
发布于 2023-09-02 / 143 阅读 / 0 评论 / 0 点赞

解决Jupyter无法保存(413: Request Entity Too Large )

问题描述

jupyer lab界面保存文件时提示Jupyter Lab throwing 413: Request Entity Too Large

解决方法

  1. 修改nginx配置,在配置中增加/修改client_max_body_size
    完整配置文件为
upstream my-notebook-workhorse {
  server 127.0.0.1:8888 fail_timeout=0;
}

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

# let my-notebook deal with the redirection
server {
  listen                    80;
  server_name               my-notebook.wh;
  server_tokens             off;
  root                      /dev/null;

  # Increase this if you want to upload larger attachments
  client_max_body_size      64m;

  # individual nginx logs for this vhost
  access_log                /var/log/nginx/my-notebook_access.log;
  error_log                 /var/log/nginx/my-notebook_error.log;

  location / {
    proxy_pass http://my-notebook-workhorse;
    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 X-NginX-Proxy true;
    auth_basic "Restricted Content";

    # WebSocket support
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Origin "";
    proxy_read_timeout 86400;
  }
}
  1. 重新启动nginx后保存正常
docker-compose restart nginx

或重新加载nginx配置文件

docker exec <dockername> nginx -s reload

Reference

  1. https://juejin.cn/post/6844904120457887751
  2. https://www.msl.la/archives/413/

评论