使用nginx反向代理jupyter无法保存文件
今天登录jupyter发现之前写的notebook文件无法正常保存,回想最近的修改无非就是添加了nginx反向代理,所以就比较容易追溯问题.想必就是nginx限制了保存文件的最大上限.
413 Request Entity Too Large
nginx 配置:
修改nginx 对应的config, 常规会是在
/etc/nginx/sites-enabled/xxxx.conf
添加client_max_body_size 设定为预期值.
该设定可以按预期设定到http/server/location,定制具体的设定项;
选择在http{ }中设置:client_max_body_size 20m;
也可以选择在server{ }中设置;
还可以选择在location{ }中设置;
三者的区别
设置到http{}内,控制全局nginx所有请求报文大小
设置到server{}内,控制该server的所有请求报文大小
设置到location{}内,控制满足该路由规则的请求报文大小
还可以选择在location{ }中设置;
三者的区别
设置到http{}内,控制全局nginx所有请求报文大小
设置到server{}内,控制该server的所有请求报文大小
设置到location{}内,控制满足该路由规则的请求报文大小
如果上述设定后,仍然有问题,可以修改下jupyter的config
比如
/home/xxx/.jupyter/xxxxx.conf
## Sets the maximum allowed size of the client request body, specified in the # Content-Length request header field. If the size in a request exceeds the # configured value, a malformed HTTP message is returned to the client. # # Note: max_body_size is applied even in streaming mode. #c.NotebookApp.max_body_size = 536870912
关闭前面的注释, 设置具体值即可.
如果是其它webserver, 则需要按照说明进行具体配置