Unable to navigate to the uploads folder in Nginx from frontend

Viewed 25

I am trying to reach the uploads directory from my frontend hosted in an Nginx server but it is returning a 404. The URL I am trying to react is https://example.com/uploads/logo.png

The folder structure of my Nginx server is:

Frontend: /var/www/example.com/example.com-frontend/build/
Backend: /var/www/example.com/example.com-backend/
Upload path: /var/www/example.com/example.com-backend/uploads/logo.png

My Nginx conf for frontend is something like this:

server {
    listen 80;
    listen [::]:80;
    server_name example.com www. example.com;
    return 302 https://$server_name$request_uri;
}
server {
    # SSL configuration
 
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl_certificate         /etc/ssl/certs/cert.pem;
    ssl_certificate_key     /etc/ssl/private/key.pem;
 
    server_name example.com www. example.com;
 
    root /var/www/example.com/example.com-frontend/build;
    index index.html index.htm index.nginx-debian.html;
 
    location / {
        try_files $uri /index.html;
    }
 
    location /api {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
 
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect off;
    }
 
    location ^~ /uploads {
        root /var/www/example.com/example.com-backend/uploads;
    }
}

I am not able to map the uploads path to my uploads path inside the backend directory. The file permissions are -rwxr-xr-x

0 Answers
Related