与 mod_wsgi 相关的 Django https ssl 配置错误

Django https ssl configuration error related to mod_wsgi

我将我的 Django 项目部署到 AWS Linux AMI 认为是 Elastic Beanstalk。 目前,它在 http 上运行良好,但在 https 上,它显示如下错误。

[:error] [pid 3090] [client 24.43.39.130:64135] Embedded mode of mod_wsgi disabled by runtime configuration: /opt/python/current/app/connectshops/wsgi.py

我一直在努力调试这个错误,但我还没弄明白。 有谁知道出了什么问题?我应该在我的 ssl.conf 文件中添加一些配置吗?

编辑

/opt/httpd/conf.d/wsgi.conf

LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/python/run/baselinenv
WSGISocketPrefix run/wsgi
WSGIRestrictEmbedded On

<VirtualHost *:80>

  Alias /static/ /opt/python/current/app/static/
  <Directory /opt/python/current/app/static/>
    Order allow,deny
    Allow from all
  </Directory>


  WSGIScriptAlias / /opt/python/current/app/connectshops/wsgi.py


  <Directory /opt/python/current/app/>
    Require all granted
  </Directory>

  WSGIDaemonProcess wsgi processes=1 threads=15 display-name=%{GROUP} \
  python-home=/opt/python/run/venv/ \
  python-path=/opt/python/current/app:/opt/python/run/venv/lib64/python3.6/site-packages:/opt/python/run/venv/lib/python3.6/site-packages user=wsgi group=wsgi \
  home=/opt/python/current/app
  WSGIProcessGroup wsgi
</VirtualHost>

LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" comb$

这是我 wsgi.conf 中的代码。正如您所说,我目前正在启用 WSGIRestrictEmbedded,但我不确定我现在正在使用其中的哪一个。 只是想让你知道,我有相同的 VirtualHost 代码 *:443

尝试使用:

  WSGIDaemonProcess wsgi processes=1 threads=15 display-name=%{GROUP} \
      python-home=/opt/python/run/venv/ \
      python-path=/opt/python/current/app user=wsgi group=wsgi \
      home=/opt/python/current/app

  WSGIScriptAlias / /opt/python/current/app/connectshops/wsgi.py process-group=wsgi

  <Directory /opt/python/current/app/>
    Require all granted
  </Directory>

我没有发现您的内容有任何特别的错误,但是已经更改了顺序并使用 process-group 而不是 WSGIProcessGroup

还删除了 python-path 中不需要添加的目录。

单独保留 WSGIRestrictEmbedded 指令。