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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题