Opened 9 years ago

Closed 8 years ago

#170 closed defect (invalid)

nginx sending incorrect header

Reported by: Michael Jephcote Owned by: somebody
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: apache json headers Cc:
uname -a: Linux vibesn.com 2.6.18-274.7.1.el5
nginx -V: nginx version: nginx/1.3.0
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)

Description

Hi,

I have nginx configured as a proxy to Apache and when requesting JSON data nginx seems to be sending an incorrect header corrupting the response. It works as expected when accessed through Apache without nginx.

The URL being requested: http://jira.vibesn.com/rest/gadget/1.0/favfilters?showCounts=true
The Response headers:

Date: Mon, 21 May 2012 11:08:55 GMT
Content-Encoding: , gzip
X-AREQUESTID: 728x7680x1
Server: nginx
Vary: Accept-Encoding,
Content-Type: application/json;charset=UTF-8
Cache-Control: max-age=86400
X-AUSERNAME: anonymous
Expires: Tue, 22 May 2012 11:08:55 GMT
200 OK

Take a look at the Content-Encoding and Vary headers, they contain commas and undue spaces.

Change History (4)

comment:1 by Maxim Dounin, 9 years ago

Priority: majorminor

This looks like backend problem, not nginx one. Could you please provide nginx config and debug log (see http://wiki.nginx.org/Debugging for details)?

comment:2 by Michael Jephcote, 9 years ago

2012/05/21 15:55:59 [notice] 9141#0: using the "epoll" event method
2012/05/21 15:55:59 [notice] 9141#0: nginx/1.3.0
2012/05/21 15:55:59 [notice] 9141#0: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
2012/05/21 15:55:59 [notice] 9141#0: OS: Linux 2.6.18-274.7.1.el5xen
2012/05/21 15:55:59 [notice] 9141#0: getrlimit(RLIMIT_NOFILE): 1024:1024
2012/05/21 15:55:59 [notice] 9142#0: start worker processes
2012/05/21 15:55:59 [notice] 9142#0: start worker process 9143
2012/05/21 15:55:59 [notice] 9142#0: start worker process 9144
2012/05/21 15:55:59 [notice] 9142#0: start worker process 9145
2012/05/21 15:55:59 [notice] 9142#0: start worker process 9146
2012/05/21 15:55:59 [notice] 9142#0: start worker process 9147
2012/05/21 15:55:59 [notice] 9142#0: start worker process 9149
2012/05/21 15:55:59 [notice] 9142#0: start cache manager process 9150
2012/05/21 15:55:59 [notice] 9142#0: start cache loader process 9151
2012/05/21 15:56:04 [notice] 9143#0: *1 "^(/manager/.*)$" does not match "/", client: 213.104.16.162, server: jira.vibesn.com, request: "GET / HTTP/1.1", ho$
2012/05/21 15:56:05 [notice] 9143#0: *1 "^(/manager/.*)$" does not match "/secure/MyJiraHome.jspa", client: 213.104.16.162, server: jira.vibesn.com, request$
2012/05/21 15:56:05 [notice] 9143#0: *1 "^(/manager/.*)$" does not match "/secure/Dashboard.jspa", client: 213.104.16.162, server: jira.vibesn.com, request:$
2012/05/21 15:56:05 [notice] 9143#0: *1 "^(/manager/.*)$" does not match "/s/en_UK-rmxple/731/17/1/_/download/superbatch/css/batch.css", client: 213.104.16.$
2012/05/21 15:56:05 [error] 9143#0: *1 open() "/var/www/vibesn/data/www/jira.vibesn.com/s/en_UK-rmxple/731/17/1/_/download/superbatch/css/batch.css" failed $
2012/05/21 15:56:05 [notice] 9143#0: *4 "^(/manager/.*)$" does not match "/s/en_UK-rmxple/731/17/3.1.21/_/download/batch/com.atlassian.gadgets.dashboard:gad$
2012/05/21 15:56:05 [error] 9143#0: *4 open() "/var/www/vibesn/data/www/jira.vibesn.com/s/en_UK-rmxple/731/17/3.1.21/_/download/batch/com.atlassian.gadgets.$
2012/05/21 15:56:05 [notice] 9143#0: *6 "^(/manager/.*)$" does not match "/s/en_UK-rmxple/731/17/1.0/_/download/batch/jira.webresources:global-static/jira.w$
#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
#   http://wiki.nginx.org/NginxHttpMainModule
#
#----------------------------------------------------------------------

user              nginx;
worker_processes  6;
worker_rlimit_nofile 100000;




error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


#----------------------------------------------------------------------
# Events Module 
#
#   http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------

events {
    worker_connections  1024;
    use epoll;
}


#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.nginx.org/NginxHttpCoreModule 
#
#----------------------------------------------------------------------

http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    log_format cache '***$time_local '
                     '$upstream_cache_status '
                     'Cache-Control: $upstream_http_cache_control '
                     'Expires: $upstream_http_expires '
                     '"$request" ($status) '
                     '"$http_user_agent" ';

    #access_log  /var/log/nginx/cache.log cache;

    sendfile on;
    ignore_invalid_headers on;
    keepalive_requests 2000;
    recursive_error_pages on;
    server_name_in_redirect on;
    server_tokens off;

    gzip on;
    gzip_http_version 1.0;
    gzip_vary on;
    gzip_comp_level 5;
    gzip_static	on;
    gzip_min_length 512;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.";

    ## Timeouts
    client_body_timeout 15;
    client_header_timeout 15;
    keepalive_timeout 15 15;
    send_timeout 15;
    expires 24h;

    ## TCP options
    tcp_nodelay off;
    tcp_nopush on;

    proxy_cache_path  /var/www/cache levels=1:2 keys_zone=vibe-cache:8m max_size=1000m inactive=600m;
    proxy_temp_path /var/www/cache/tmp;

    client_max_body_size 16m;
    log_format  isp '$bytes_sent $request_length';

	server {
		listen 91.215.159.45:80;
		server_name jira.vibesn.com www.jira.vibesn.com;
		rewrite ^(/manager/.*)$	https://$host$1	permanent;
		error_page 404 = @fallback;
		location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
			proxy_pass http://91.215.159.45:8080;
			proxy_redirect http://jira.vibesn.com:8080/ /;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location / {
			#expires 0;
			proxy_pass http://91.215.159.45:8888;
			proxy_redirect http://jira.vibesn.com:8888/ /;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
		location ~* ^.+\.(ico|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
			expires max;
			root /var/www/vibesn/data/www/jira.vibesn.com;
			access_log /var/www/httpd-logs/jira.vibesn.com.access.log ;
			access_log /var/www/nginx-logs/vibesn isp;
		}
		location @fallback {
			#expires 0;
			proxy_pass http://91.215.159.45:8888;
			proxy_set_header Host $host;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Real-IP $remote_addr;
		}
	}
}

comment:3 by Maxim Dounin, 9 years ago

The log provided isn't debug one. You have to compile nginx with --with-debug configure option to obtain debug log. Quoting the wiki page I've already linked:

To activate debugging log you have to compile nginx with --with-debug configure option and set debug level in error_log directive.

You clearly missed the first step.

comment:4 by Maxim Dounin, 8 years ago

Resolution: invalid
Status: newclosed

Feedback timeout. Real issue seems to be backend which incorrectly sends empty Content-Encoding header.

Note: See TracTickets for help on using tickets.