djangodockernginxgoogle-app-engineapp-engine-flexible

Where is nginx.conf kept on Google App Engine flexible environment?


I am getting nginx.error:

client intended to send too large body

so I'm trying to fix by making changes to nginx.conf. This is in a Google App Engine that uses Django and deploys to the flexible environment with a Dockerfile. It executes gunicorn to start the app.

My nginx.conf file is in the same directory as my app.yaml file.

So far, I've tried copying nginx.conf to /etc/nginx/nginx.conf in the Dockerfile just before starting gunicorn.
I've tried naming the file nginx-app.conf as suggested elsewhere.
I've tried commenting out the entire nginx.conf file to see if it is being used.

In every case, I get the "client intended to send too large body" error.

Where does nginx.conf live in the flexible environment? Can I change it and copy it to where it needs to be as part of my Dockerfile?

Current Dockerfile:

    FROM ubuntu:bionic
    
    RUN apt-get -y update && apt-get -y upgrade \ ...
    RUN pip3 install virtualenv
    RUN virtualenv -p python3.8 env
    ENV VIRTUAL_ENV /env
    ENV PATH /env/bin:$PATH
    ADD requirements.txt /app/requirements.txt
    RUN pip install -r /app/requirements.txt
    ADD . /app
    WORKDIR /app    
    ENV PORT 8000
    EXPOSE 8000    
    COPY nginx.conf /etc/nginx/nginx.conf
    CMD exec gunicorn --workers 2 --threads 8 -b :$PORT mysite.wsgi:application

My current nginx.conf:

    events {
        worker_connections 768;
    }
    
    http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
    
        access_log /var/log/app_engine/app.log;
        error_log /var/log/app_engine/app.log;
    
        gzip on;
        gzip_disable "msie6";
    
        server {
            listen 8080; (have also tried 8080 ssl;)
            directio 4096;
            root /usr/share/nginx/www;
            index index.html index.htm;
            sendfile on;
            sendfile_max_chunk 1m;
            client_max_body_size 500M;
        }
    }

Note, I've also increased both FILE_UPLOAD_MAX_MEMORY_SIZE and DATA_UPLOAD_MAX_MEMORY_SIZE in Django's settings.

Thanks for any help that's out there!


Solution

  • DazWilkin solved in the comments. App Engine limits Requests to 32MB

    Thank you DazWilkin