Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

client sent invalid header line in Nginx

Tags:

nginx

in Nginx error log file , getting error as

client sent invalid header line: "LocalDBUser_CREATE|USERNAME: User1" while reading client request headers

How to fix this issue.

My Nginx Conf file is

#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;
    }

Please let me know how to fix the error

like image 562
user2439278 Avatar asked Jul 09 '14 10:07

user2439278


3 Answers

I guess, you need directive ignore_invalid_headers off.

like image 190
Alexey Ten Avatar answered Nov 02 '22 02:11

Alexey Ten


In this case you need: underscores_in_headers on;

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

Valid names are composed of English letters, digits, hyphens, and possibly underscores

like image 32
David Sommer Avatar answered Nov 02 '22 04:11

David Sommer


i had same problem. you need just remove from config of vhost

proxy_set_header Host $host;
like image 2
James M Avatar answered Nov 02 '22 03:11

James M