Django 在 HTTPS 上显示 500 内部服务器错误

标签 django ssl https apache2 mod-wsgi

我在 apache2 目录的 error.log 中收到以下错误:Segmentation fault (11), possible coredump in/etc/apache2

我的 example-instance.conf 中有以下配置:

 ErrorDocument 404 "/error-pages/404.html"
 ErrorDocument 500 "/error-pages/500.html"
 ErrorDocument 403 "/error-pages/403.html"

 # Change the following three lines for your server

 ServerName example.app
 SetEnv HTTP_HOST "example.app"
 ServerAdmin admin@example.app

 SetEnv LC_TIME "en_GB.UTF-8"
 SetEnv LANG "en_US.UTF-8"

 SSLEngine on

 SSLCertificateFile "path/to/certificate"
 SSLCertificateChainFile "path/to/certificate"
 SSLCertificateKeyFile "path/to/private_key"

 WSGIScriptAlias /app "path/to/wsgi_prod.py"

 # Comment next 2 lines if using older Apache than v2.4
 WSGIApplicationGroup %{GLOBAL}
 WSGIDaemonProcess instance1_wsgi python-path="__PATH_TO_ENV_SITE-PACKAGES_FOLDER__"
 WSGIProcessGroup instance1_wsgi

 # Comment 'Require all granted' for older Apache than v2.4

 <Location "/">
   Require all granted
   Options FollowSymLinks
 </Location>

 Alias /static/ "path/to/static/"
 Alias /app/static/ "path/to/static/"
 <Directory "path/to/static/">
   Require all granted
   Options -Indexes
 </Directory>

 Alias /data/ "path/to/data/"
 <Directory "path/to/data/">
   Require all granted
   Options -Indexes
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/example-instance-error.log
 LogLevel warn
 CustomLog ${APACHE_LOG_DIR}/example-instance-access.log combined

该站点在 http 上运行良好,但是在为 https 配置它时,我在“/app”上收到 500 Internal Server Error我的 Django 应用所在的子目录。该网站的登录页面完全正常,这表明 https 正在运行。

最佳答案

我有同样的问题:/目前唯一的选择是关闭 mod_ssl 并返回到配置文件中的端口 80。

奇怪的是我在 settings.py 中有 Debug = True 但是当应用程序崩溃时我只收到来自 apache 的错误 500 页面。

关于Django 在 HTTPS 上显示 500 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59381574/

相关文章:

python - 如何修复django模板中的html代码

Java JSSE SSLEngine 无法恢复 SSL session

php - PayPal证书升级&加密网站支付

security - 让客户选择首选的 SSL/TLS 证书

python - Django 功能 View VS 类 RedirectView。如何使类 View 接受参数

python - Django Save 创建两条记录而不是一条

ssl - SIM800L GSM 模块使用 http 工作,但使用 https 时显示错误,为什么?

Grails - 检测请求是通过 HTTP 还是 HTTPS

java - 获取 HTTPS 连接的响应码

python - 如何在Python Django的设置中启用每日新的日志文件名?