1

I followed the example: How to upload multiple files with django rest api? The solution work in localhost, but when i upload to nginx server running in a container docker, the nginx return a error 400, i can't more details because i'm not getting log, my nginx configuration it is like this:

upstream api {
    server neworleansenglishcourse.com.br:8000;
}

server {
    listen 80;
    server_name neworleansenglishcourse.com.br www.neworleansenglishcourse.com.br;

    location / {
        client_max_body_size 8000M;
        client_body_buffer_size 8000M;
        client_body_timeout 120;
        root /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    location /api/ {
        client_max_body_size 8000M;
        client_body_buffer_size 8000M;
        client_body_timeout 120;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Url-Scheme $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_pass http://api;
    }

    location /complementos/ {
        client_max_body_size 8000M;
        client_body_buffer_size 8000M;
        client_body_timeout 120;
    }

}

My docker compose it is like this:

version: '3'

services:
    backend:
        build:
            context: ./api
        command: gunicorn plataformaingles.wsgi --bind 0.0.0.0:8000
        ports:
            - "8000:8000"
        depends_on:
            - db
        networks: 
            - production-network
    frontend:
        build:
            context: ./front
        volumes:
            - front_build:/front/build
        networks: 
            - production-network
    nginx:
        image: nginx:latest
        ports:
            - "80:80"
        volumes:
            - ./nginx/nginx-setup.conf:/etc/nginx/conf.d/default.conf
            - front_build:/usr/share/nginx/html
        depends_on:
            - backend
            - frontend
        networks: 
            - production-network    
volumes:
    front_build:             
networks: 
    production-network:
        driver: bridge

1 Answer 1

0

Might be too late for you, but I had the same problem today that my multiple=True file field only worked on localhost. I noticed that I had slightly different Django installations locally (3.2.16) and in docker (3.2.20). I solved it by downgrading the Django version in my docker container to 3.2.16.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.