nginx serving Django in a subdirectory through uWSGI

前端 未结 5 2021
别跟我提以往
别跟我提以往 2021-02-19 15:48

I have already gone through some previous threads: How do I set subdirectory in nginx with Django how to deploy django under a suburl behind nginx Serving flask app on subdirect

5条回答
  •  礼貌的吻别
    2021-02-19 16:09

    First of all, remove uwsgi_modifier1 30;. Django will handle SCRIPT_NAME by itself and don't need to have PATH_INFO rewritten by uWSGI. It can be harmful if SCRIPT_NAME isn't removed from headers by uWSGI.

    Secondly, remove uwsgi_param PATH_INFO "$1"; from nginx config. PATH_INFO is already defined in uwsgi_params file, and it should be $document_uri (as it is in uwsgi_params), not $1 if you're passing SCRIPT_NAME to django.

    After that tweaks, django should treat SCRIPT_NAME as URL prefix and will adjust url dispatcher and url reversing to that.

提交回复
热议问题