I'm currently facing an issue with uploading images and videos in my Next.js application hosted on a VPS. Despite modifying the permissions for the necessary directories, I'm still unable to upload any media files. Here are the details of my setup:nextjs 14, nginx, PM2 and VPS Ubuntu
I have set the permissions for the public directory:
sudo chown -R ubuntu:ubuntu /var/www/nextjs/Project/publicsudo chmod -R 755 /var/www/nextjs/Project/publicnginx configuration:
server { listen 80; server_name (mydomain); client_max_body_size 100M; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location /_next/static/ { alias /var/www/nextjs/Project/.next/static/; expires 365d; access_log off; } location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { access_log off; log_not_found off; expires 365d; add_header Cache-Control "public, max-age=31536000, immutable"; } location /recipe_img/ { alias /var/www/nextjs/Project/public/recipe_img/; access_log off; expires max; } location /tips_img/ { alias /var/www/nextjs/Project/public/tips_img/; access_log off; expires max; } location /recipe_video/ { alias /var/www/nextjs/Project/public/recipe_video/; access_log off; expires max; } location /tips_video/ { alias /var/www/nextjs/Project/public/tips_video/; access_log off; expires max; }}And when I run:
pm2 logsI got:
And when I run:
sudo tail -f /var/log/nginx/error.logI got:
Could anyone provide insights or suggestions on what else I might be missing or need to check? Any help would be greatly appreciated!

