You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to upload via the form from the example module configuration, the file in the designated directory does not appear, the directory obviously exists and for the time of testing I gave it 777 permissions. Below are the logs generated when uploading the file:
tail -f /usr/local/nginx/logs/access.log
x.x.x.x - - [30/Jan/2023:15:50:14 +0000] "GET /upload/upload.html HTTP/1.1" 200 587 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
x.x.x.x - user [30/Jan/2023:15:50:14 +0000] "POST /upload HTTP/1.1" 301 169 "http://x.x.x.x/upload/upload.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
x.x.x.x - user [30/Jan/2023:15:50:18 +0000] "GET /upload/ HTTP/1.1" 200 277 "http://x.x.x.x/upload/upload.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
I spent whole night trying to fix the same issue. Just as @maro584, i gave up on using the default upload_store /tmp/upload 1;, because even though the subdirectories clearly exist and have the correct permissions (ended up with 777), the error.log was telling me (2: No such file or directory). Switching to upload_store /tmp stopped throwing any errors or messages at all, however the files were actually never saving in /tmp/, and trying different locations such as /var/tmp and so on didn't help. I also tried using different users in the nginx.conf's user directive, including my own working user to ensure it's not a permissions/access issue.
Things suddenly started working when I changed the line to upload_store /var/log/nginx/;, which of course is ridiculous and wrong, but it's the place nginx 100% can access, and indeed, the files started uploading. I don't know anything about nginx' inner structure and thus have no idea why it doesn't allow itself not just accessing but "seeing" any directories outside of the working dir paths defined when compiling, maybe it's the default behavior for security reasons, maybe I missed some obscure compilation flag that would allow this.
So, I guess my advice is to implement a temporary solution, save the files into one of the nginx directories and make your backend scripts instantly move them to a better location if you plan to use nginx as a fast local proxy for testing your python/ruby/php webapp, or switch to Apache if you need a production web server, that would save you a lot of time. Honestly, it's depressing how there is little to no online help about such issues in nginx and its modules.
I used the following documentation to complete the setup:
https://www.nginx.com/resources/wiki/modules/upload/
When trying to upload via the form from the example module configuration, the file in the designated directory does not appear, the directory obviously exists and for the time of testing I gave it 777 permissions. Below are the logs generated when uploading the file:
tail -f /usr/local/nginx/logs/access.log
x.x.x.x - - [30/Jan/2023:15:50:14 +0000] "GET /upload/upload.html HTTP/1.1" 200 587 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
x.x.x.x - user [30/Jan/2023:15:50:14 +0000] "POST /upload HTTP/1.1" 301 169 "http://x.x.x.x/upload/upload.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
x.x.x.x - user [30/Jan/2023:15:50:18 +0000] "GET /upload/ HTTP/1.1" 200 277 "http://x.x.x.x/upload/upload.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
upload.html
<title>Test upload</title>Select files to upload
nginx.conf
#user nobody;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
}
Directory z for files, despite using the configuration, is empty, the uploaded files are small, a few Kb.
nginx version: nginx/1.20.2
Red Hat Enterprise Linux release 8.7 (Ootpa)
The text was updated successfully, but these errors were encountered: