Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

上传附件报错,求帮助 #1146

Closed
jiangqiang1996 opened this issue Nov 11, 2020 · 6 comments
Closed

上传附件报错,求帮助 #1146

jiangqiang1996 opened this issue Nov 11, 2020 · 6 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@jiangqiang1996
Copy link
Contributor

QQ截图20201111104310

halo自己没有上传的日志,应该是nginx有问题,看见浏览器控制台网络响应的是
`

<title>413 Request Entity Too Large</title>

413 Request Entity Too Large


nginx `

附件大小22M
使用了nginx代理,但是nginx设置了最大body为1024m
22

@jiangqiang1996 jiangqiang1996 added the kind/bug Categorizes issue or PR as related to a bug. label Nov 11, 2020
@ruibaby ruibaby added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed kind/bug Categorizes issue or PR as related to a bug. labels Nov 11, 2020
@ruibaby
Copy link
Member

ruibaby commented Nov 11, 2020

nginx 有重载配置或者重启吗?

@jiangqiang1996
Copy link
Contributor Author

nginx 有重载配置或者重启吗?

有重启,上面是我最新的配置。加了一些超时时间的配置,然后浏览器上传之后直接就告诉我网络错误了。浏览器没响应。不加后面几个时间的配置就是413错误。

@ruibaby
Copy link
Member

ruibaby commented Nov 11, 2020

@jiangqiang2020 那就不太清楚了,这不属于 Halo 的问题,建议你在网上搜索解决方案。

@jiangqiang1996
Copy link
Contributor Author

@jiangqiang2020 那就不太清楚了,这不属于 Halo 的问题,建议你在网上搜索解决方案。

解决了。感谢。nginx的server和location都配置了大小,location只配置了10m。location优先级高,所以报错。另外,需要把nginx的超时时间设置大点才能正常上传。但是发现了一个问题:页面显示上传进度达到100之后得等很久才会告诉你上传成功,后台日志应该看出这段时间应该是上传到oss,这段时间间隔太长,页面没有一点互动效果,给人感觉就是卡死了,体验不好。

@ruibaby
Copy link
Member

ruibaby commented Nov 11, 2020

@jiangqiang2020 那就不太清楚了,这不属于 Halo 的问题,建议你在网上搜索解决方案。

解决了。感谢。nginx的server和location都配置了大小,location只配置了10m。location优先级高,所以报错。另外,需要把nginx的超时时间设置大点才能正常上传。但是发现了一个问题:页面显示上传进度达到100之后得等很久才会告诉你上传成功,后台日志应该看出这段时间应该是上传到oss,这段时间间隔太长,页面没有一点互动效果,给人感觉就是卡死了,体验不好。

啊是的,之前考虑不周,oss上传是先经过服务器,而不是直接在客户端上传到 oss,所以会造成这一个现象。后面会重构附件上传,改为直接在客户端上传。

@jiangqiang1996
Copy link
Contributor Author

最后贴一个配置,希望可以帮助其他人,下面这段配置加在自己的nginx配置里面。
` location /api/admin/attachments/ {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            #add_header Access-Control-Allow-Origin *;
            #proxy_set_header  Host $host:$server_port;
            client_max_body_size  100m;

            client_body_timeout      5m;
            proxy_connect_timeout     60s;
            proxy_read_timeout      5m;
            proxy_send_timeout      5m;

            proxy_pass http://localhost:8090/api/admin/attachments/;
    }

`

@ruibaby ruibaby closed this as completed Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

No branches or pull requests

2 participants