J
J
John2016-12-03 12:59:27
Nginx
John, 2016-12-03 12:59:27

NodeJS how to fix 502 error when uploading files?

There is a site on NodeJS framework AdonisJS . Everything would be fine, but when uploading files over 2MB, the server falls on a 502 error. Writes to the log

2016/12/03 12:25:12 [error] 2034#2034: *2504 upstream prematurely closed connection while reading response header from upstream, client: 37.215.112.153, server: adonis.ml, request: "POST /manager/albums /1/ HTTP/1.1", upstream: " 127.0.0.1:3000/manager/albums/1 ", host: "adonis.ml", referrer: " https://adonis.ml/manager/albums/1/ "

Here is the entire Nginx configuration file ( /etc/nginx/nginx.conf )
user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
  worker_connections 768;
  # multi_accept on;
}

http {
  client_max_body_size 100M;

  ##
  # Basic Settings
  ##

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 3600s;
  types_hash_max_size 2048;
  # server_tokens on;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

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

  ##
  # SSL Settings
  ##

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  ##
  # Logging Settings
  ##

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

  ##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";

  # gzip_vary on;
  # gzip_proxied any;
  # gzip_comp_level 6;
  # gzip_buffers 16 8k;
  # gzip_http_version 1.1;
  # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  ##
  # Virtual Host Configs
  ##

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

In the settings of the framework itself, there is permission to upload files up to 2Gig
Please help me solve the problem 502
Host config
server { 
      listen 443 ssl; 
      ssl on; 
      ssl_certificate /etc/letsencrypt/live/adonis.ml/fullchain.pem; 
      ssl_certificate_key /etc/letsencrypt/live/adonis.ml/privkey.pem; 

      root /gopanel/sites/adonis_ml/public_html; 
      index index.php index.html index.htm; 

      server_name adonis.ml; 

      include /etc/roundcube/webmail_configuration;
      include /etc/phpmyadmin/nginx.conf;

     location / {
        proxy_read_timeout  2400s;
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

      location ~ \.php$ { 
           try_files $uri =404; 
           fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
           fastcgi_param HTTP_PROXY ""; 
           fastcgi_index index.php; 
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
           include fastcgi_params; 
      } 
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question