Nginx — static file serving confusion with root & alias

前端 未结 7 1318
[愿得一人]
[愿得一人] 2020-11-22 15:29

I need to serve my app through my app server at 8080, and my static files from a directory without touching the app server. The nginx config I have is something

7条回答
  •  感动是毒
    2020-11-22 16:22

    server {
        server_name xyz.com;
        root /home/ubuntu/project_folder/;
    
        client_max_body_size 10M;
        access_log  /var/log/nginx/project.access.log;
        error_log  /var/log/nginx/project.error.log;
    
        location /static {
            index index.html;
        }
    
        location /media {
            alias /home/ubuntu/project/media/;
        }
    }
    

    Server block to live the static page on nginx.

提交回复
热议问题