Nginx“ 400请求标头或Cookie太大”问题

问题描述

我的springboot应用程序从nginx获得了400个Bad Request请求标头或cookie太大,因为JWT密钥为38.7kb。当我使用较小的JWT密钥时,一切都很好。我尝试通过在服务器上下文中添加nginx的配置来修改它。

    client_header_buffer_size 64k;
    large_client_header_buffers 4 64k;
    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;

不幸的是,nginx仍然返回相同的400 Bad Request。奇怪的是,我在nginx错误日志中找不到任何跟踪。我的操作系统是centOS 7.6,nginx版本是1.18.1。

这是我完整的nginx配置文件。

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;


# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s;
    limit_conn_zone $binary_remote_addr zone=two:10m;
     

server {
    keepalive_requests 120; 
    listen       80;   
    server_name  10.254.9.31;     

    client_header_buffer_size 64k;
    large_client_header_buffers 4 64k;
    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;

    location /api {
   #limit_conn two 1;
   #limit_req  zone=one burst=2 nodelay;
   proxy_pass http://commonapi/;
    }


   location /isse-auth/ {
   proxy_pass http://10.254.9.31:8888/;
    }


    } 

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)