Skip to content

fix: Allow upload limit increase in kubernetes deployment #7664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Dexter192
Copy link
Contributor

@Dexter192 Dexter192 commented Apr 16, 2025

For kubernetes deployments, the maximum filesize for e.g. File Components is capped at 1MB due to the Nginx default limit

Since the Nginx service is started via a start-nginx.sh file, adding annotations to the ingress part of the values.yaml does not work
e.g.

ingress:
  enabled: true
  annotations:
    nginx.ingress.kubernetes.io/client-max-body-size: "200M"

or

frontend:
  nginx:
    client_max_body_size: "200M" 

The workaround described in the helm repo also does not work (for me) since the ingress.yaml template sets the service name and port for every path identically:

service:
  name: {{ $fullName }}
    port: 
      number: {{ $svcPort }}

The proposed change would allow the configuration of the client_max_body_size for the nginx configuration while using the existing environment variable LANGFLOW_MAX_FILE_SIZE_UPLOAD. Reusing this variable makes sense as it's purpose is to configure the maximum upload size.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 16, 2025
@github-actions github-actions bot added the bug Something isn't working label Apr 16, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Apr 16, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Apr 16, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Apr 16, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Apr 16, 2025
@jrespeto
Copy link

jrespeto commented May 9, 2025

I was looking into this issue today and saw this PR.

The envsubst is not editing the nginx.conf file.

Maybe move the docker/frontend/nginx.conf changes you have to docker/frontend/default.conf.template to inside the http block and change the __LANGFLOW_MAX_FILE_SIZE_UPLOAD__ to ${LANGFLOW_MAX_FILE_SIZE_UPLOAD} to match the other variables.

@Dexter192
Copy link
Contributor Author

@jrespeto Thanks for the pointer! You're absolutely right. I missed the copy part in the Dockerfile

I'll apply your suggestions when I get some time for it next week!

@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels May 12, 2025
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice.

Thank you @Dexter192

Have you tested it thoroughly?

@jrespeto
Copy link

I implemented the changes in my environment by patching the container image and confirm it does work.
Thanks @Dexter192

dockerfile

FROM langflowai/langflow-frontend:latest as langflow-frontend

COPY --chown=nginx src/default.conf.template /etc/nginx/conf.d/default.conf.template
COPY --chown=nginx --chmod=755 src/start-nginx.sh /start-nginx.sh

ENTRYPOINT ["/start-nginx.sh"]

default.conf.template

worker_processes auto;
pid /tmp/nginx.pid;
events {}

http {
    client_max_body_size ${LANGFLOW_MAX_FILE_SIZE_UPLOAD}M;
    include /etc/nginx/mime.types;
    default_type text/plain;

    types {
        text/html html;
        text/css css;
        application/javascript js;
    }

    server {
        gzip on;
        gzip_comp_level 2;
        gzip_min_length 1000;
        gzip_types text/xml text/css;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_disable "MSIE [4-6] \.";

        listen ${FRONTEND_PORT};

        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
            try_files $uri $uri/ /index.html =404;
            expires 1d;
            add_header Cache-Control "public";
        }
        location = /index.html {
            root /usr/share/nginx/html;
            add_header Cache-Control "no-cache, no-store, must-revalidate";
            etag on;
        }

        location /api {
            proxy_pass ${BACKEND_URL};
        }
        location /health_check {
            proxy_pass ${BACKEND_URL};
        }
        location /health {
            proxy_pass ${BACKEND_URL};
        }

        include /etc/nginx/extra-conf.d/*.conf;
    }
}

start-nginx.sh

#!/bin/sh
set -e

# Define writable directory for the final config
CONFIG_DIR="/tmp/nginx"
mkdir -p $CONFIG_DIR

# Check and set environment variables
if [ -z "$BACKEND_URL" ]; then
  BACKEND_URL="$1"
fi
if [ -z "$FRONTEND_PORT" ]; then
  FRONTEND_PORT="$2"
fi
if [ -z "$FRONTEND_PORT" ]; then
  FRONTEND_PORT="80"
fi
if [ -z "$LANGFLOW_MAX_FILE_SIZE_UPLOAD" ]; then
  LANGFLOW_MAX_FILE_SIZE_UPLOAD="1"
fi
if [ -z "$BACKEND_URL" ]; then
  echo "BACKEND_URL must be set as an environment variable or as first parameter. (e.g. http://localhost:7860)"
  exit 1
fi

# Export variables for envsubst
export BACKEND_URL FRONTEND_PORT LANGFLOW_MAX_FILE_SIZE_UPLOAD

# Use envsubst to substitute environment variables in the template
envsubst '${BACKEND_URL} ${FRONTEND_PORT} ${LANGFLOW_MAX_FILE_SIZE_UPLOAD}' < /etc/nginx/conf.d/default.conf.template > $CONFIG_DIR/default.conf

# Start nginx with the new configuration
exec nginx -c $CONFIG_DIR/default.conf -g 'daemon off;'

@Dexter192
Copy link
Contributor Author

@ogabrielluiz I have built a docker image with the modification and deployed it on kubernetes cluster to validate that the changes work.

When deploying the image using Helm, some additional changes to the frontend helm template are required.

For testing I simply added this to the env block:

{{with .Values.langflow.frontend.env }}
{{- toYaml . | nindent 12 }}
{{- end }}

It might be better to reference the value from the backend env block since the env variable is used in the Langflow backend as well. However, this would increase the dependency of the frontend and backend part in the chart.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 21, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels May 21, 2025
@Dexter192 Dexter192 requested a review from ogabrielluiz June 3, 2025 11:39
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Jun 3, 2025
Merged via the queue into langflow-ai:main with commit 9191773 Jun 3, 2025
10 checks passed
@Dexter192 Dexter192 deleted the feat/increase_nginx_upload_limit branch June 3, 2025 12:25
dev-thiago-oliver pushed a commit to vvidai/langflow that referenced this pull request Jun 10, 2025
…i#7664)

* Add nginx body size upload limit config

* Add nginx body size upload limit config

* Rename env variable to match existing max upload

* Rename env variable to match existing max upload

* Add export of Max_file_size_upload variable

* Add unit to max body size

* Remove unit from default assignment

* Apply comments and move config to default nginx conf template

---------

Co-authored-by: daniel.kaestner <[email protected]>
Co-authored-by: Dexter192 <[email protected]>
dev-thiago-oliver pushed a commit to vvidai/langflow that referenced this pull request Jun 17, 2025
…i#7664)

* Add nginx body size upload limit config

* Add nginx body size upload limit config

* Rename env variable to match existing max upload

* Rename env variable to match existing max upload

* Add export of Max_file_size_upload variable

* Add unit to max body size

* Remove unit from default assignment

* Apply comments and move config to default nginx conf template

---------

Co-authored-by: daniel.kaestner <[email protected]>
Co-authored-by: Dexter192 <[email protected]>
dev-thiago-oliver pushed a commit to vvidai/langflow that referenced this pull request Jun 22, 2025
…i#7664)

* Add nginx body size upload limit config

* Add nginx body size upload limit config

* Rename env variable to match existing max upload

* Rename env variable to match existing max upload

* Add export of Max_file_size_upload variable

* Add unit to max body size

* Remove unit from default assignment

* Apply comments and move config to default nginx conf template

---------

Co-authored-by: daniel.kaestner <[email protected]>
Co-authored-by: Dexter192 <[email protected]>
ogabrielluiz pushed a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
…i#7664)

* Add nginx body size upload limit config

* Add nginx body size upload limit config

* Rename env variable to match existing max upload

* Rename env variable to match existing max upload

* Add export of Max_file_size_upload variable

* Add unit to max body size

* Remove unit from default assignment

* Apply comments and move config to default nginx conf template

---------

Co-authored-by: daniel.kaestner <[email protected]>
Co-authored-by: Dexter192 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants