开发者社区> 问答> 正文

400 Bad Request Request Header Or Cookie Too Large nginx

我在网上看了一天了,都是修改client_header_buffer_size 16k;与large_client_header_buffers 4 46k;但是我已经调大了但是还是没用!Linux的ssh的端口号被安全拦截了我重新写了一个端口号重启了一下服务器后就报这个错!请问一下大神怎么解决啊?

展开
收起
聚石惠 2017-03-29 16:20:11 13804 0
4 条回答
写回答
取消 提交回答
  • 解决了吗?我也是这种问题

    2020-02-18 20:23:35
    赞同 展开评论 打赏
  • 学无止境,是技术行业的必要准则,学如逆水行舟不进则退……

    client_header_buffer_size 16k
    我设置了这个后出现404了

    2019-07-17 20:59:22
    赞同 展开评论 打赏
  • http {

    include       mime.types;
    default_type  application/octet-stream;
    
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
    #access_log  logs/access.log  main;
    
    sendfile        on;
    #tcp_nopush     on;
    
    #keepalive_timeout  0;
    keepalive_timeout  65;
    
    client_header_buffer_size 16K;
    large_client_header_buffers 4 64K;
    client_body_buffer_size  512k;
    client_max_body_size 10m;
          
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
    proxy_connect_timeout    300;
    proxy_read_timeout       300; 
    proxy_send_timeout       300;
    proxy_buffer_size        32k; 
    proxy_buffers            4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k; 
    proxy_headers_hash_max_size 51200;
    proxy_headers_hash_bucket_size 6400;
    gzip  on;
    
    server {
        listen    80;
                server_name localhost test.jsh178.com;
        #       index index.html index.htm;
        #       rewrite ^(.*) https://$host$1 permanent;
                access_log   off;
                location / {
                  proxy_next_upstream http_502 http_504 error timeout invalid_header;
                  proxy_set_header X-Forwarded-For $http_x_forwarded_for;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header Host $Host;
                  proxy_pass http://127.0.0.1:8080;
                  error_page 404 = /404.html;
                }
        }

    HTTPS server

    #
    server {
        listen 443;
        server_name test.jsh178.com; 
        ssl on;
        ssl_certificate 1_test.jsh178.com_bundle.crt;
        ssl_certificate_key 2_test.jsh178.com.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        location / {
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_set_header X-Forwarded-For $http_x_forwarded_for;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header Host $Host;
                 proxy_pass http://127.0.0.1:8080;
                 error_page 404 = /404.html;
      }
    }
    

    这个是我的Nginx的配置

    2019-07-17 20:59:22
    赞同 展开评论 打赏
  • 贴出你的配置会让问题的解决变得更加有效率。

    2019-07-17 20:59:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载