2017-04-24 22:06
浏览 117

使用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:


    解决 无用
    打赏 举报

相关推荐 更多相似问题