I have created a flask application and deployed it in a remote ubuntu server using Nginx and uwsgi. But I can't access images in the application folder. The images are stored in /myproject/static/images/ folder.
Here is the server block
server {
listen 80;
server_name _;
location / {
include uwsgi_params;
uwsgi_pass unix:/root/myproject_sock/myproject.sock;
}
}
How can I access the images kept in /myproject/static/images/ folder through image URL i.e. HTTP://myip/myproject/static/images/first_image.jpg ?
Thanks to @RichardSmith (https://stackoverflow.com/users/4862445/richard-smith) the issue is solved.
If you are facing the same problem, you need to edit your server block inside /etc/nginx/sites-available/myproject
(myproject can be anything you named your project earlier).
You need to add location
and root
directive. for example: location /DIR_NAME/myproject/static/images/ { root /; }
. Here inside DIR_NAME
you need to put the parent directory of your myproject
folder.