I am trying to upload a 2GB file in django using nginx. The file is uploaded upto 100% and then suddenly it terminates and 502 Bad Gateway error is displayed in nginx.
Below is my application configurations
upstream app_server {
server unix:/home/training/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
# add here the ip address of your server
# or a domain pointing to that ip (like example.com or www.example.com)
server_name training.academy;
keepalive_timeout 30;
client_max_body_size 4G;
access_log /home/training/logs/nginx-access.log;
error_log /home/training/logs/nginx-error.log;
location /static/ {
alias /home/training/trainingapp/static/;
}
location /media/ {
alias /home/training/trainingapp/media/;
}
# checks for static file, if not found proxy to app
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_read_timeout 1200;
proxy_connect_timeout 1200;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_pass http://app_server;
proxy_intercept_errors on;
}
}
And below is the gunicorn start configs
#!/bin/bash
NAME="training"
DIR=/home/training/trainingapp
USER=training
GROUP=training
WORKERS=300
TIMEOUT=1200
BIND=unix:/home/training/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=training.settings
DJANGO_WSGI_MODULE=training.wsgi
LOG_LEVEL=error
cd $DIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $WORKERS \
--user=$USER \
--group=$GROUP \
--bind=$BIND \
--log-level=$LOG_LEVEL \
--log-file=-
How can I correct this error so that i can get a full and complete upload of the file and not the 502 error?