Getting 400 Bad request from my django app deployed on ec2
Recently i deployed my django app on aws ec2 using nginx and gunicorn. i followed this tutorial
And it was successful and working fine, i was also able to make requests to this app from my deployed website,then i tried uploading a file and i got an error when i checked the logs from ec2 console this was the error
2025/03/04 06:07:17 [error] 5327#5327: *5047 client intended to send too large body: 2008288 bytes, client: 152.59.11.203, server: backendapp.caresanctum.com, request: "POST /api/upload-file/ HTTP/1.1", host: "backendapp.caresanctum.com", referrer: "https://webapp.caresanctum.com/"
and ever since this i have not been able to open my base url, i get a 400 bad request error , this is so strange, i did not even open my aws console to change anything.What maybe causing this. Please let me know if more information is needed
P.S
I have also checked wether gunicorn and nginx are running or not, and they are running successfully.
also this is my django.conf
file for nginx
server{
listen 80;
server_name backendapp.caresanctum.com www.backendapp.caresanctum.com;
return 301 https://$host$request_uri;
}
server{
listen 443 ssl;
server_name backendapp.caresanctum.com www.backendapp.caresanctum.com;
ssl_certificate /etc/letsencrypt/live/backendapp.caresanctum.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/backendapp.caresanctum.com/privkey.pem;
client_max_body_size 10M;
location / {
include proxy_params;
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_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/home/ubuntu/Care-Backend/app.sock;
}
location /static/ {
alias /home/ubuntu/Care-Backend/care_app/static/;
try_files $uri $uri/ =404;
}
}