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

时间:2018-04-06 20:35:33

标签: django ssl https 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

1 个答案:

答案 0 :(得分:2)

尝试使用:

  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指令。