nginx serving Django in a subdirectory through uWSGI

前端 未结 5 1995
别跟我提以往
别跟我提以往 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:10

    The nginx uwsgi_modifier1 is deprecated in uWSGI.

    Your goal is to be able to host a wsgi app from anywhere without the app needing to be adjusted to account for where it's being served from.

    The current method for doing this in uWSGI is to map mountpoints for each URI app combination like so:

    [uwsgi]
    socket = 127.0.0.1:3031
    ; mount apps
    mount = /app1=app1.py
    mount = /app2=app2.py
    ; rewrite SCRIPT_NAME and PATH_INFO accordingly
    manage-script-name = true
    

    Hosting multiple apps in the same process (aka managing SCRIPT_NAME and PATH_INFO)

    mount can take the place of module

    For Django specifically,

    ; Before
    module = django_app.wsgi:application
    ; After
    mount = /django_app=django_app.wsgi:application
    manage-script-name = true
    

提交回复
热议问题