OCSInventory-NG / OCSInventory-Docker-Image

Docker image for OCSInventory Server
GNU General Public License v3.0
80 stars 96 forks source link

Upload of MSI file in Package builder fails with "413 Request Entity Too Large" #118

Open int-red opened 4 months ago

int-red commented 4 months ago

It's hard to solve a problem when important details are missing, that why we added this template, to help you and us.

General informations

Docker host's operating system : Alpine Linux 3.20.1 Mysql Server version : 8.0

Docker informations

Docker compose version : v2.27.0 Docker version : 26.1.3

Problem's description

Describe your problem here

I deployed a docker stack with your /2.12.2/docker-compose.yml using the instructions from https://wiki.ocsinventory-ng.org/13.Docker-documentation/Using-the-docker-image/ chapter "OCS Inventory image with Mariadb and Proxy (using docker-compose)"

git clone https://github.com/OCSInventory-NG/OCSInventory-Docker-Image cd 2.12.2/ docker compose up -d

the only modification I made to docker-compose.yml was to enable HTTPS:

diff --git a/2.12.2/docker-compose.yml b/2.12.2/docker-compose.yml
index cb52b40..99508fb 100644
--- a/2.12.2/docker-compose.yml
+++ b/2.12.2/docker-compose.yml
@@ -58,9 +58,9 @@ services:
       - ./nginx/auth:/etc/nginx/auth
     environment:
       # 80 or 443
-      LISTEN_PORT: 80
+      LISTEN_PORT: 443
       # empty or ssl
-      PORT_TYPE: ""
+      PORT_TYPE: "ssl"
       SSL_CERT: ocs-dummy.crt
       SSL_KEY: ocs-dummy.key
       # OCS Api user restriction (default ocsapi/ocapi)

The docker stack is running well. Only the upload of files is not working.

I tried to build a deployment package from an MSI using /ocsreports/index.php?function=tele_build but when I click on the "Validate" button I always get the error

413 Request Entity Too Large nginx/1.27.0

although the MSI file I tried to deploy is only 1.87MB in size.

int-red commented 4 months ago

I found out that Docker Image 2.12.2 has two issues:

  1. Docker Image 2.12.2 uses PHP 8.1.2 but in /conf/ocsinventory-reports.conf PHP tuning is only set for PHP5 + PHP7. So I added for PHP8:
    # Duplicate for php8 compatibility
    <IfModule mod_php.c>
        AddType application/x-httpd-php .php
        php_flag file_uploads           on
        # Some PHP tuning for deployment feature up to 8 MB
        # post_max_size must be greater than upload_max_filesize
        # because of HTTP headers
        php_value post_max_size         1025m
        php_value upload_max_filesize   1024m
        # You may have to uncomment following on errors
        php_value max_execution_time -1
        php_value max_input_time -1

        # Uncomment following if you need to specify a mysql socket
        #php_value mysql.default_socket "path/to/mysql/unix/socket"

        #!! Mandatory !! : set magic_quotes_gpc to off (to make ocsreports works correctly)
        php_flag magic_quotes_gpc      off
    </IfModule>
  1. Nginx settings for timeouts and client_max_body_size are only applied to URL /download. But for upload of installers this is also needed for URL /ocsreports

I modified /nginx/conf/ocsinventory.conf.template accordingly:

diff --git a/2.12.2/nginx/conf/ocsinventory.conf.template b/2.12.2/nginx/conf/ocsinventory.conf.template
index a31d5c0..bd08af2 100644
--- a/2.12.2/nginx/conf/ocsinventory.conf.template
+++ b/2.12.2/nginx/conf/ocsinventory.conf.template
@@ -32,6 +32,10 @@ server {
         proxy_set_header        X-Real-IP         $remote_addr;
         proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;
         proxy_set_header        X-Frame-Options   SAMEORIGIN;
+        proxy_read_timeout      ${READ_TIMEOUT};
+        proxy_connect_timeout   ${CONNECT_TIMEOUT};
+        proxy_send_timeout      ${SEND_TIMEOUT};
+        client_max_body_size    ${MAX_BODY_SIZE};
         proxy_pass              http://ocsapplication;
     }

With these modification the package building for the MSI file I tried to deploy first, and which is only 1.87MB in size, works.

But for larger installers I still got issues. I tried to build a package with about 400MB in size. The upload for this file starts but then the process does not complete and I get an empty web page with no error message. In /download/ a subdirectory for this package is created but the directory is empty.