[alert]: fastcgi request record is too big -Fastcgi 收到 get 请求过长的错误消息

[alert]: fastcgi request record is too big -Fastcgi 收到 get 请求过长的错误消息

最近程序遇到一个问题,LNMP环境下,由于PHP在程序中拼接的GET请求uri参数太长,导致出错,nginx处理uri过长可以通过client_head_buffer_size参数进行处理,但是当nginx收到uri请求转发给PHP时,fastcgi无法处理请求而出错(没有考虑将请求改为post)。

系统:linux CentOS7 nginx:1.14.0 php:7.2.0

Apache 解决方案:

Add a few parameters to the configuration file LimitRequestLine 40940 LimitRequestFieldSize 40940

Nginx解决方案:

**How to increase the limit of fastcgi to accept uri parameter size?**

user              test;
worker_processes  2;
worker_cpu_affinity 0101 1010;
worker_rlimit_nofile 65535;

events {
    use epoll;
    worker_connections  65535;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
include              mime.types;
default_type application/octet-stream;
charset utf-8;
sendfile                     on;
tcp_nopush                   on;
keepalive_timeout          300s;
client_header_timeout      300s;
client_body_timeout        300s;
client_max_body_size       100m;
client_body_buffer_size   2048k;
client_header_buffer_size  1024k;
large_client_header_buffers 32 64k;
send_timeout               300s;
fastcgi_connect_timeout    300s;
fastcgi_send_timeout       300s;
fastcgi_read_timeout       300s;
fastcgi_buffer_size       1024k;
fastcgi_buffers          64 64k;
fastcgi_busy_buffers_size  2048k;
fastcgi_temp_file_write_size 2048k;
gzip                         on;
gzip_min_length              1k;
gzip_buffers             16 16k;
gzip_http_version           1.1;
gzip_types text/plain text/css application/javascript application/xml;
gzip_comp_level               3;
gzip_vary                    on;
server_names_hash_max_size  512;
server_names_hash_bucket_size  128;
include /*.conf;
}

Fastcgi错误日志[1]:https://i.stack.imgur.com/lzV4H.png

请帮忙!!!SOS

答案1

似乎无法仅从 nginx 或 php-fpm 方面解决这个问题,但仍然可以在应用程序级别修复,因为升级 client_body_buffer 并不是一种真正有效的方法(但作为一种解决方法你可以尝试,尽管我建议不要这样做)。

请参见此主题

相关内容