duanbing6955 2017-04-24 22:06
浏览 119
已采纳

使用NGINX,Laravel Forge通过AJAX上传PHP vimeo上的502 Bad Gateway

I'm using Laravel (5.4) Forge for a web app that uploads Vimeo and Youtube videos from S3. In the past, before moving to Forge, this script worked correctly, and also still works correctly with smaller files today.

Now that I'm trying to upload larger files (~1gb), Im receiving a 502 Bad Gateway after just over 1 minute for the php upload script. The rest of the application runs fine.

Specifically, here is the error:

2017/04/24 20:36:48 [error] 2111#2111: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: X.X.X.X.X, server: myserver.com, request: "POST /recordings/vimeo/upload HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock:", host: "myserver.com", referrer: "http://myserver.com/recordings"

I have tried:

  • adding / editing fastcgi directives in the nginx config
  • upping output_buffering in php
  • adding the proxy_ and client_max_body items below

Here's my NGINX config:

include forge-conf/myserver.com/before/*;

server {
    listen 80;
    listen [::]:80;
    server_name .myserver.com;
    root /home/forge/myserver.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'hidden for SO';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    include forge-conf/myserver.com/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/myserver.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 3600;
        fastcgi_buffers 8 512k;
        fastcgi_buffer_size 512k;

        include fastcgi_params;


        client_max_body_size 128M;
        proxy_buffer_size 256k; 
        proxy_buffers 4 512k;
        proxy_busy_buffers_size 512k;

    }

    location ~ /\.ht {
        deny all;
    }
}

include forge-conf/myserver.com/after/*;

What am I missing? I can't seem to figure this out at all. Thank you in advance for the help.

  • 写回答

1条回答 默认 最新

  • dqjo4340 2017-04-26 20:27
    关注

    "request_terminate_timeout" turned out to be the issue:

    https://laracasts.com/discuss/channels/forge/502-bad-gateway-with-large-file-uploads

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵