为了账号安全,请及时绑定邮箱和手机立即绑定

Nginx 和 PHP-FPM - 下载大小限制在 ~3MB

Nginx 和 PHP-FPM - 下载大小限制在 ~3MB

PHP
慕仙森 2021-06-11 14:08:26
我有一个 CSV 下载,使用 Docker、Nginx 和 PHP-FPM,一切运行良好,直到下载变得更大然后 2-3 MB。生成的 CSV 文件存在于 php 容器中(在我的 tmp 目录 /var/www/symfony/var/tmp/... 看起来不错),但 Nginx 无法为它们提供服务。Nginx 错误日志显示了这一点2019/05/09 12:09:29 [crit] 7#7: *747 open() "/var/tmp/nginx/fastcgi/2/07/0000000072" failed (13: Permission denied) 同时读取上游,客户端: 172.18.0.1, server: , request: "GET /catalog-download HTTP/1.1", upstream: "fastcgi://172.18.0.3:9001", host: "localhost", referrer: " http://localhost/目录”看起来我的 csv 文件不在那里,Nginx 或其他人应该将它们移到 Nginx tmp 文件夹中。有一些关于 Nginx 下载问题的帖子,但大多数都有 300MB 和更大的问题。所以我认为我的问题是不同的。下载很好,但限制 < ~2-3MB。Nginx 配置是user www;worker_processes 4;pid /run/nginx.pid;events {    worker_connections  2048;    multi_accept on;    use epoll;}http {    server_tokens off;    sendfile on;    tcp_nopush on;    tcp_nodelay on;    keepalive_timeout 15;    types_hash_max_size 2048;    include /etc/nginx/mime.types;    default_type application/octet-stream;    access_log off;    error_log off;    gzip on;    gzip_disable "msie6";    include /etc/nginx/conf.d/*.conf;    include /etc/nginx/sites-enabled/*;    open_file_cache max=100;    client_body_temp_path /tmp 1 2;    client_body_buffer_size 256k;    client_body_in_file_only off;    client_max_body_size 50M;}和upstream php-upstream {    server php:9001;}server {    listen 80;    server_name mydomain.tk;    server_tokens off;    location /.well-known/acme-challenge/ {        root /var/www/certbot;    }    location / {        return 301 https://$host$request_uri;    }}server {    listen 443 ssl;    server_name mydomain.tk;    server_tokens off;    ssl_certificate /etc/letsencrypt/live/mydomain.tk/fullchain.pem;    ssl_certificate_key /etc/letsencrypt/live/mydomain.tk/privkey.pem;    include /etc/letsencrypt/options-ssl-nginx.conf;    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;    root /var/www/symfony/public;    location / {        try_files $uri /index.php$is_args$args;    }
查看完整描述

2 回答

?
慕桂英4014372

TA贡献1871条经验 获得超13个赞

php.ini文件中搜索以下文本:

; 是否允许 HTTP 文件上传。file_uploads = 开

; HTTP 上传文件的临时目录(如果未指定,将使用系统默认值)。

;upload_tmp_dir =

; 上传文件的最大允许大小。上传最大文件大小 = 128M


查看完整回答
反对 回复 2021-06-13
?
狐的传说

TA贡献1804条经验 获得超3个赞

幸运的是,在阅读这篇文章后,我找到了解决方案

https://serverfault.com/questions/235154/permission-denied-while-reading-upstream

我添加了权限“chown www.www /var/tmp/nginx/”所以nginx可以使用他的tmp文件夹。

看起来,当文件大于 2-3 MB 时,nginx 只需要自己的 tmp 文件夹。非常棘手。我认为权利存在,因为小下载工作......


查看完整回答
反对 回复 2021-06-13
  • 2 回答
  • 0 关注
  • 199 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信