Fetching static files failed with 404 in nginx

后端 未结 2 1318
陌清茗
陌清茗 2021-02-01 04:50

I\'m now deploying an django app with nginx and gunicorn on ubuntu 12.

And I configure the nginx virtual host file as below:

server {
    listen 80;
             


        
2条回答
  •  悲&欢浪女
    2021-02-01 05:14

    You should use alias instead of root. root appends the trailing URL parts to your local path (e.g. http://test.ndd/trailing/part, it will add /trailing/part to your local path). Instead of that, alias does exactly what you want: when http://test.ndd/static/ is requested, /static is mapped to your alias exactly, without appending static again.

提交回复
热议问题