Increase nginx client_max_body_size for image uploads

By default, nginx has a small (1MB) limit on the size of uploads,
which prevents using horizon interface to upload an image. Increase
the default client_max_body_size to allow for most images to be
uploaded without having to tweak the client_max_body_size.

Additionally, make the client_max_body_size tunable via snap settings
to make it easier for users to change. This adds a new snap config
option 'config.horizon.upload.max' which allows users to tweak this
value.

Closes-Bug: #1868503
Change-Id: I0a89e0845d6c7d2805556f87685d280b4e72122a
This commit is contained in:
Billy Olsen 2021-03-30 10:31:17 -07:00 committed by Billy Olsen
parent b42d532c45
commit 1fce2529f6
3 changed files with 5 additions and 0 deletions

View File

@ -75,6 +75,9 @@ def _get_default_config():
'config.nova.cpu-mode': 'host-model', 'config.nova.cpu-mode': 'host-model',
# Do not override cpu-models by default. # Do not override cpu-models by default.
'config.nova.cpu-models': '', 'config.nova.cpu-models': '',
# Allow up to an 8G image upload by default. This is quite large
# but should allow for some larger images by default (e.g. Windows)
'config.horizon.upload.max': '8G',
} }

View File

@ -108,6 +108,7 @@ setup:
dns_domain: 'config.network.dns-domain' dns_domain: 'config.network.dns-domain'
dashboard_allowed_hosts: 'config.network.dashboard-allowed-hosts' dashboard_allowed_hosts: 'config.network.dashboard-allowed-hosts'
dashboard_port: 'config.network.ports.dashboard' dashboard_port: 'config.network.ports.dashboard'
max_upload_size: 'config.horizon.upload.max'
mysql_port: 'config.network.ports.mysql' mysql_port: 'config.network.ports.mysql'
rabbit_port: 'config.network.ports.rabbit' rabbit_port: 'config.network.ports.rabbit'
logging_debug: 'config.logging.debug' logging_debug: 'config.logging.debug'

View File

@ -15,6 +15,7 @@ http {
tcp_nopush on; tcp_nopush on;
tcp_nodelay on; tcp_nodelay on;
keepalive_timeout 65; keepalive_timeout 65;
client_max_body_size {{ max_upload_size }};
types_hash_max_size 2048; types_hash_max_size 2048;
include {{ snap }}/usr/conf/mime.types; include {{ snap }}/usr/conf/mime.types;