How do I set subdirectory in nginx with Django

后端 未结 2 889
醉话见心
醉话见心 2021-01-15 00:10

Environment:

  • uwsgi
  • nginx
  • django 1.3

I\'m using the domain www.example.com with Django and nginx, and I want to ac

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-15 00:12

    According to the uWSGI on Nginx docs, you just have to pass the SCRIPT_NAME to django.

    location /abc {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9000;
        uwsgi_param SCRIPT_NAME /abc;            
    }
    

    Django will still "see" /abc, but it should deal with it so that it gets stripped off before your urls are matched. You want this to happen, if django didn't see /abc, it would generate incorrect urls for your site and none of your links would work.

提交回复
热议问题