I'm trying to use gunicorn to serve static files before configuring nginx as reverse proxy and I got a little bit confused.
When I run my applications it seems like gunicorn is not able to find the static folder into the application.
I have the following script to run my Django application.
#!/bin/bash
# Start with development server
# echo Start server.
# python manage.py runserver 0.0.0.0:8000
# python manage.py collectstatic --noinput # Collect static files
# # Prepare log files and start outputting logs to stdout
touch /srv/logs/gunicorn.log
touch /srv/logs/access.log
tail -n 0 -f /srv/logs/*.log &
# # Start Gunicorn processes
echo Starting Gunicorn.
exec gunicorn django_project.wsgi:application \
--name ds4dems \
--bind 0.0.0.0:8000 \
--workers 3 \
--log-level=info \
--log-file=/srv/logs/gunicorn.log \
--access-logfile=/srv/logs/access.log \
"$@"
The result is that style and images are not collected from main_app static folder.
Folder structure is the following.
django_project
---- django_project
---- main_app
-------- static
Following I tried to run the same application with development server and the statics are collected. Then I rerun with Gunicorn and styles and images are served to the browser without errors.
What exactly is going on?
Does it have to do with this? Is the only available option to set nginx to let him see the files?