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;

    # 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:


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



    • ¥15 深海控制器DSE7320MKII和博世ECU间can通讯知识
    • ¥15 Ru的复折射率用于FDTD 200nm到1200nm
    • ¥15 使用Fiddler抓包,textview的乱码如何解决
    • ¥50 trio连接驱动器报错
    • ¥15 有谁懂nhanes的权重计算啊
    • ¥15 欧姆龙PLC 电机控制 限位
    • ¥30 如何处理shell命令接收到的视频流并实时播放出来
    • ¥15 虚心请教C#的代码优化问题
    • ¥15 有偿求做台风过境全过程模拟仿真
    • ¥50 求!AutomationDesk 如何自动导入Variant数据