客户端在Nginx中发送了无效的标题行

use*_*278 7 nginx

在Nginx错误日志文件中,获取错误为

客户端在读取客户端请求标头时发送了无效标题行:"LocalDBUser_CREATE | USERNAME:User1"

如何解决这个问题.

我的Nginx Conf文件是

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}     
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;

    #gzip  on;
        upstream uic_entry {
    server 127.0.0.1:4005;
        }

 server {
        listen       80;
        server_name  xxx.yyy.com;
        underscores_in_headers on;
            large_client_header_buffers 4 16k;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503         http_504;
           proxy_redirect off;
            proxy_buffering off;
           proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-NginX-Proxy true;
             proxy_read_timeout 200;

    location / {
        #root   html;
        #index  index.html index.htm;
        #return 503;
                proxy_pass          http://uic_entry;
    }
Run Code Online (Sandbox Code Playgroud)

请让我知道如何修复错误

Ale*_*Ten 7

我想,你需要指令ignore_invalid_headers off.

  • 添加它,还是删除它?OP 似乎需要“允许”无效标头?如果您解释说他的标头包含无效字符,并且只要应用程序不需要该标头,OP 就可以使 nginx 忽略格式错误的标头,那就太好了... (2认同)

小智 6

在这种情况下,您需要: underscores_in_headers on;

http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers

有效名称由英文字母、数字、连字符和可能的下划线组成