PHP vimeo 上的 502 Bad Gateway 通过 AJAX 使用 NGINX 上传,Laravel Forge
502 Bad Gateway on PHP vimeo upload via AJAX with NGINX, Laravel Forge
我正在使用 Laravel (5.4) Forge 作为从 S3 上传 Vimeo 和 Youtube 视频的网络应用程序。过去,在迁移到 Forge 之前,此脚本可以正常工作,并且在今天处理较小的文件时仍然可以正常工作。
现在我正在尝试上传更大的文件 (~1gb),我在 php 上传脚本的 1 分钟多一点后收到 502 Bad Gateway。应用程序的其余部分运行良好。
具体来说,这里是错误:
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"
我试过:
- 在 nginx 配置中添加/编辑 fastcgi 指令
- 在 php
中增加 output_buffering
- 在下面添加 proxy_ 和 client_max_body 项
这是我的 NGINX 配置:
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/*;
我错过了什么?我似乎无法弄清楚这一点。预先感谢您的帮助。
"request_terminate_timeout" 结果是问题所在:
https://laracasts.com/discuss/channels/forge/502-bad-gateway-with-large-file-uploads
我有同样的 502 问题,经过一些调试后发现我在 nginx 中达到了极限,而不是 PHP 中的问题。
将以下内容添加到我的站点 conf,现在一切正常:
server{
fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;
#...our rest of config
}
通常您可以在里面找到 nginx
配置文件
/etc/nginx/sites-available/default
或
/etc/nginx/sites-available/your_domain.com
我正在使用 Laravel (5.4) Forge 作为从 S3 上传 Vimeo 和 Youtube 视频的网络应用程序。过去,在迁移到 Forge 之前,此脚本可以正常工作,并且在今天处理较小的文件时仍然可以正常工作。
现在我正在尝试上传更大的文件 (~1gb),我在 php 上传脚本的 1 分钟多一点后收到 502 Bad Gateway。应用程序的其余部分运行良好。
具体来说,这里是错误:
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"
我试过:
- 在 nginx 配置中添加/编辑 fastcgi 指令
- 在 php 中增加 output_buffering
- 在下面添加 proxy_ 和 client_max_body 项
这是我的 NGINX 配置:
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/*;
我错过了什么?我似乎无法弄清楚这一点。预先感谢您的帮助。
"request_terminate_timeout" 结果是问题所在:
https://laracasts.com/discuss/channels/forge/502-bad-gateway-with-large-file-uploads
我有同样的 502 问题,经过一些调试后发现我在 nginx 中达到了极限,而不是 PHP 中的问题。
将以下内容添加到我的站点 conf,现在一切正常:
server{
fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;
#...our rest of config
}
通常您可以在里面找到 nginx
配置文件
/etc/nginx/sites-available/default
或
/etc/nginx/sites-available/your_domain.com