I was setting up basic Django site with nginx. When i navigate to the url of the file i get error 404 Not Found
nginx/1.18.0 (Ubuntu)
This is the conf file
upstream django {
server unix:///home/jo/testproject/testproject.sock;
}
# configuration of the server
server {
listen 80;
server_name _;
charset utf-8;
# max upload size
client_max_body_size 75M;
# Django media and static files
location /media/ {
alias /home/jo/testproject/media/;
}
location /static {
alias /home/jo/testproject/static;
}
# Send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/jo/testproject/uwsgi_params;
}
}
the media folder is in /home/jo/testproject/media and inside it i have media.gif, but ip/media/media.gif doesnt work
when i write the ip in the browser i get
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
I think everything else i setup correctly
3
Answers
Docker + NGINX + Gunicorn + Django
Django project:
Dockerfile:
docker-compose.yml:
nginx/Dockerfile:
nginx/nginx.conf:
settings.py:
the upstream component nginx needs to connect to
then
finally
I also faced this problem and I add this in my sudo nano /etc/nginx/sites-available/project file
where Images is my image folder that contains uploaded images