0

i tested a lot of recomendations found on Stackoverflow or on other sites, but none of them helped me. I need to change the max file size for nginx for fileupload. It was recomended to add client_max_body_size to the html section. So I did this. My config looks like this. And everything expected file upload is working. Very small files can be uploaded.

    worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    client_max_body_size 200M;

    keepalive_timeout  65;
    gzip  on;

    server {
        listen       80;
        listen [::]:80;
        server_name  localhost;
       
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";

        charset utf-8;
        
        root   T:/Nathan/public;     

        location / {
            index index.html index.htm index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;
        
        location ~ \.php$ {
            try_files $uri /index.php = 404;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_connect_timeout 75;
            fastcgi_send_timeout 600;
            fastcgi_read_timeout 600;
        }
        
        location ~ /\.(?!well-known).* {
           deny  all;
        }
    }
}

Testing the config with nginx.exe -t

T:\nginx-1.22.1>nginx.exe -t
nginx: the configuration file T:\nginx-1.22.1/conf/nginx.conf syntax is ok
nginx: configuration file T:\nginx-1.22.1/conf/nginx.conf test is successful

But file upload is still on default setting. Testing the bigger files with the php buildin server are working fine.

I think, I did something wrong and cant help myself anymore. Hope someone can help me with this.

Timo

TimoBickert
  • 60
  • 1
  • 6

0 Answers0