I have two servers: the first for Nginx and the second for Django + media files.
Nginx server IP: xxx.xx.xx.1
Django + media files server IP: xxx.xx.xx.2
In Django's settings.py file, my media path configurations:
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = "/media/"
In the first server, my Nginx configurations:
server {
listen 80;
server_name example.com;
location /media/ {
proxy_pass http://xxx.xx.xx.2/;
}
location / {
include proxy_params;
proxy_pass http://xxx.xx.xx.2:8000/;
}
}
In the second server, where the media files are placed, my Nginx configurations:
server {
listen 80;
server_name xxx.xx.xx.2;
location /media/ {
alias /home/sadm/Desktop/{project_name}/media;
}
However, when trying to access example.com/media/images/my_image.jpg, I get a 404 error.
Any help is greatly appreciated! Thanks in advance!