Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meinheld + NGINX proxy causes content truncation #84

Closed
tylfin opened this issue Aug 2, 2017 · 4 comments
Closed

Meinheld + NGINX proxy causes content truncation #84

tylfin opened this issue Aug 2, 2017 · 4 comments

Comments

@tylfin
Copy link

tylfin commented Aug 2, 2017

Hey guys,

Had an ELB -> NGINX -> Gunicorn + Meinheld and kept getting a net::ERR_CONTENT_LENGTH_MISMATCH when I disabled cache via chrome console. Once I removed Meinheld everything worked. Not sure what the issue was, but here's the NGINX config and the run command.

Run command:

gunicorn -w $(($(nproc) * 2 + 1)) -t 60 --worker-class="egg:meinheld#gunicorn_worker" --bind 0.0.0.0:5000 app:app

Proxy config:

    map $http_upgrade $connection_upgrade {
        default        "upgrade";
        ""            "";
    }
    
    server {
        listen 80;

    	gzip on;
	    gzip_comp_level 4;
	    gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
            set $year $1;
            set $month $2;
            set $day $3;
            set $hour $4;
        }
        access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;

        access_log    /var/log/nginx/access.log;
    
        location / {
            proxy_pass            http://docker;
            proxy_http_version    1.1;
    
            proxy_set_header    Connection            $connection_upgrade;
            proxy_set_header    Upgrade                $http_upgrade;
            proxy_set_header    Host                $host;
            proxy_set_header    X-Real-IP            $remote_addr;
            proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
        }
    }

and NGINX.conf

user  nginx;
worker_processes  auto;

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

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

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

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

    log_format  healthd '$msec"$uri"$status"$request_time"$upstream_response_time"$http_x_forwarded_for';

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

@gerasim13
Copy link

I had the same situation, after switching to another worker problems got away

@tylfin
Copy link
Author

tylfin commented Oct 2, 2017

@gerasim13 I ended up removing meinheld too.

@agalera
Copy link

agalera commented Oct 5, 2017

use meinheld patch?

maybe it is possible to be of interest

bottlepy/bottle#896

@methane
Copy link
Collaborator

methane commented Nov 13, 2019

It can be happened when app set wrong Content-Length header.

I close this issue because it is too outdated.
Please provide reproducible example next time it happened.

@methane methane closed this as completed Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants