Django- session cookies and sites on multiple ports

前端 未结 2 1299
梦谈多话
梦谈多话 2021-02-01 08:51

I have multiple Django projects running on one server using gunicorn and nginx. Currently they are each configured to run on a unique port of the same IP address using the serve

相关标签:
2条回答
  • 2021-02-01 09:16

    Just change the SESSION_COOKIE_NAME. The SESSION_COOKIE_DOMAIN doesn't support port numbers afaik. So they are all the same for your apps.

    0 讨论(0)
  • 2021-02-01 09:26

    Another solution that doesn't require hard-coding different cookie names for each site is to write a middleware that changes the cookie name based on the port the request came in on.

    Here's a simple version (just a few lines of code).

    0 讨论(0)
提交回复
热议问题