0

I have a web application (developped with the java framework Play) behind a nginx reverse-proxy. When I request the pages, the bigger CSS files (Bootstrap.min.css and easyui.css) don't load. Chrome console displays net::ERR_CONTENT_LENGTH_MISMATCH for those files. Effectively, the Content-Length header is 121260 (approx 118Ko) for bootstrap.min.css but only 20,73Ko are transferred.

My Nginx version is 1.10.1 (formerly 1.2.1 before I passed with the debian testing version).

Here are the uncommented parts of my nginx.conf (I disabled gzip because I read the problem could be caused by compression, but it didn't solved anything) :

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

server_names_hash_bucket_size 64;

include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip off;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

}

My proxy.conf file (in conf.d) :

proxy_redirect          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_hide_header       X-Powered-By;
client_max_body_size    16m;
client_body_buffer_size 128k;
client_header_buffer_size 64k;
proxy_connect_timeout   300;
proxy_send_timeout      300;
proxy_read_timeout      300;
proxy_buffer_size   16k;
proxy_buffers       32   16k;
proxy_busy_buffers_size 64k;

proxy_cache_key "$scheme://$host$request_uri";
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache:10m inactive=7d max_size=700m;

The configuration file of my web application :

server {

    listen 80;
    server_name foo.bar.net;
    access_log /var/log/nginx/default.access.log;
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 444;
}

location / {
    proxy_http_version 1.1;
    proxy_pass http://192.168.1.5:9002/;
    proxy_cache off;
    proxy_buffering off;
    expires -1s;
}

location ^~ (^/admin|^/identification) {
    proxy_pass http://192.168.1.5:9002;
}

error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505 506 507 /error.html;

location = /error.html {
    root /var/www/nginx-default;
}
}

The nginx error log :

2016/06/10 15:22:05 [error] 28538#28538: *2446 upstream prematurely closed connection while sending to client, client: 172.16.1.2, server: foo.bar.net, request: "GET /assets/bootstrap-3.3.6-dist/css/bootstrap.min.css HTTP/1.1", upstream: "http://192.168.1.5:9002/assets/bootstrap-3.3.6-dist/css/bootstrap.min.css", host: "foo.bar.net", referrer: "http://foo.bar.net/"
  • The error log says "upstream prematurely closed connection". That suggests that the problem isn't with Nginx, it's with whatever you're proxying too. – Tim Jun 10 '16 at 18:43
  • Did you ever solve this? I have the same problem – Redzarf Dec 05 '17 at 12:36

0 Answers0