如何在Apache的Sub URI下正确提供Django站点?

时间:2019-04-13 01:02:54

标签: django apache

我正在尝试在另一个站点的子URI中提供Mayan EDMS(一个Django项目)。已经检查并遵循了这些帖子中的说明:

1)https://gitlab.com/mayan-edms/mayan-edms/issues/350

2)How to host a Django project in a subpath?

3)https://docs.webfaction.com/software/django/config.html#mounting-a-django-application-on-a-subpath

这是我的apache配置的一部分:

  # Mayan in running on http://0.0.0.0:8000

  ProxyPass /mayan http://127.0.0.1:8000
  <Directory "/mayan">
      Options FollowSymLinks Indexes
      SetHandler uwsgi-handler
  </Directory>

  Alias "/mayan-static" "/opt/mayan/mayan-edms/media/static/"
  <Location "/mayan-static">
      SetHandler None
      Require all granted
  </Location>

我将它们添加到Django设置文件中:

USE_X_FORWARDED_HOST  = True
FORCE_SCRIPT_NAME     = '/mayan' 
BASE_PATH             = '/mayan'
STATIC_URL            = '/mayan-static/'
MEDIA_URL             = BASE_PATH + '/media/'

我希望Mayan会加载到http://example.com/mayan中, 但它重定向到http://example.com/#/mayan并返回404错误。

我错过了什么吗?还是我做错了什么?