-
Notifications
You must be signed in to change notification settings - Fork 7k
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
fix: Allow upload limit increase in kubernetes deployment #7664
Conversation
I was looking into this issue today and saw this PR. The Maybe move the |
@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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the changes in my environment by patching the container image and confirm it does work.
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"]
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;
}
}
#!/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;'
|
@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:
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. |
…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]>
…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]>
…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]>
…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]>
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.
or
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:
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.