Reputation: 51
I get hit with the error
413 Request Entity Too Large
when I try to upload any file larger than 1.5MB.
I have seen various answers out there regarding this issue but nothing seems to work with my situation:
my nginx default.conf:
upstream django {
server store:27038;
}
server {
listen 27036;
location /static {
alias /vol/static;
}
location / {
proxy_pass http://django;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
my nginx Dockerfile:
FROM nginxinc/nginx-unprivileged:1-alpine
COPY ./default.conf /etc/nginx/conf.d/default.conf
USER root
RUN mkdir -p /vol/static
RUN chmod 777 /vol/static
USER nginx
I keep on seeing responses saying that just adding something like
server {
client_max_body_size 100M;
...
}
somewhere in Nginx should solve the issue but I keep getting an error when I try to put it on my conf file so am not entirely sure where this code is supposed to go. If anyone has an answer for this it would be much appreciated
Upvotes: 2
Views: 2074
Reputation: 51
So funny enough there seemed to be some sort of caching issue on my dockerfile so the changes didn't properly take effect, thus the reason why the solution wasn't working:
upstream django {
server store:27038;
}
server {
client_max_body_size 100M;
listen 27036;
location /static {
alias /vol/static;
}
location / {
proxy_pass http://django;
proxy_set_header X-Forwarded-For $
proxy_set_header Host $host;
proxy_redirect off;
}
}
This did the trick for me. Simply adding the client_max_body_size 100M
and rebuilding the image from scratch.
Upvotes: 1