Nginx 1.5+ file downloads - best practices

I want to upload files through my nginx server. I am currently running nginx-1.4.6 and wish to switch to the latest stable nginx-1.5* as needed.

Favorite community is Valery Kholodkov nginx-upload-module , found here . Unfortunately, Valery no longer supports this module, details are here . Starting with nginx-1.3.9 module works partially or does not work at all.

I compiled nginx-upload-module in nginx-1.4.6 and got an error (Client cxn closed), which seems to be fixed in the nginx-1.5.3 revision. However, I applied the patch and no luck.

Anatoly is slightly outdated; here , he offers several solutions, includes four solutions

When I dive into the second and fourth solutions (I prefer not to install the lua dependency, but I can), I thought it was appropriate to ask this community:

What are the current recommendations for downloading files using nginx-1.5+ ?

Add that I download files from the python POST command and try to test with curl . PHP not part of my technical stack.

+52
file-upload nginx
Mar 17 '14 at 17:36
source share
5 answers

Perhaps you can use perl if you don't like php or lua.

http://nginx.org/en/docs/http/ngx_http_perl_module.html#methods

$ r-> has_request_body (handler)

But out of the box, nginx is not a tool to save the received mail request and save it.

Maybe uWSGI ( https://uwsgi-docs.readthedocs.io/en/latest/ ) is the best way to go with http-socket https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html and application python.

+1
Sep 01 '16 at 21:03
source share
— -

There is a good article about your doubts. https://coderwall.com/p/swgfvw

I tried nginx-upload-module. This is a good solution, but it does not seem to work for new versions. There are also some modules in Lua that can help you. In my case, I had the logic of logic that I implemented in my application.

Keep in mind that the big problem for downloading files is FILER. This is a botany: many load tests that I have done have shown me this conclusion.

0
Oct 17 '14 at 1:10
source share

Nginx supports the POST method, where you can use large parameters. The client can use php or jsp to use the post method to create a request to the nginx server.

0
Jul 14 '16 at 3:12
source share

I understand that this is a very old question, but it is on the first page of Google search for the “nginx download module”, and this is the first result, so in case this helps someone else running into this question:

I am using the nginx-upload module for nginx 1.10.3. As mentioned in the original question, Valery Kholodkov no longer supports the module. However, there are several different forks, and other people modified it to work with new versions of nginx.

This port request is what I used to compile nginx with the load module.

https://github.com/vkholodkov/nginx-upload-module/pull/88

The boot module, IMO, is still the best solution if you use nginx and php-fpm. This module allows you to fully download nginx downloads until they are complete, and then the execution of the download processing will be transferred to PHP. This way php-fpm processes will not create a bottleneck when your users upload a lot of files.

0
Jun 08 '17 at 2:54 on
source share

Just a quick project, but try this ...

 Upload.php if (isset($_FILES['dlc_file']) && !empty($_FILES['dlc_file'])) { if (empty($_FILES['dlc_file']['name']) === true) { echo = "Please choose a file to upload"; } else { $allowed = array('zip', 'rar', 'gzip', 'tar', '7z', 'png', 'jpg'); $file_name = $_FILES['dlc_file']['name']; $file_extn = strtolower(end(explode('.', $file_name))); $file_temp = $_FILES['dlc_file']['tmp_name']; if (in_array($file_extn, $allowed) === true) { $file_path = 'dlc/' . substr(md5(time()), 0, 10) . '.' . $file_extn; move_uploaded_file($file_temp, $file_path); echo = "Successfully uploaded $file_name"; } else { $file_types = implode(', ', $allowed); echo "File type is not allowed, Allowed file types $file_types"; } } } index.php <form action="upload.php" method="post" enctype="multipart/form-data> <input type="file" name="dlc_file"> <input type="submit" name="submit" value="Upload"> </form> 
-7
Sep 05 '14 at 3:35
source share



All Articles