开发者社区> 问答> 正文

400 Bad Request Request Header Or Cookie Too Large nginx

聚石惠 2017-03-29 16:20:11 5817

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

安全 应用服务中间件 Linux 网络安全 nginx
分享到
取消 提交回答
全部回答(3)
  • 潇洒先
    2019-07-17 20:59:22

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

    0 0
  • 聚石惠
    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的配置

    0 0
  • 一溜
    2019-07-17 20:59:21

    贴出你的配置会让问题的解决变得更加有效率。

    0 0
添加回答

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程