Home > Software engineering >  Nginx access to images in backend folder
Nginx access to images in backend folder

Time:09-29

My app store images on the backedn side in nodejs folder: /images. After publish it to Ec2 I don't have an access to these images by url like: enter image description here

Is it the configuration problem or permission or something else? I will be grateful for help!

CodePudding user response:

The correct configuration should be:

server {
  charset utf-8;
  listen 80 default_server;
  server_name _;

  location / {
    root /opt/front-end/;
    try_files $uri /index.html;
  }

  location /api {
    proxy_pass http://localhost:4000;
  }

  location /images {
    autoindex on;
    alias /opt/back-end/images/;
  }
}
  • Related