提问人:Али Зейналов 提问时间:9/22/2023 更新时间:9/25/2023 访问量:71
我在 apache2 服务器 django 应用程序上遇到错误 无法代理来自守护程序的响应
I got error on apache2 server django application Failed to proxy response from daemon
问:
该网站仅适用于 1-2 个请求,之后它开始无休止地加载,如果我等待一段时间,我会收到内部服务器错误。 在此之后,我重新加载服务器 sudo systemctl 重新加载 apache2 网站适用于 1 个请求,我又遇到了同样的问题 (当我使用 runserver 0.0.0.0:8000 时,它工作正常)
我在 Ubuntu 22.04 上使用 django 应用程序
使用 apache2 和 libapache2-mod-wsgi-py3 Libapache 版本是:
libapache2-mod-wsgi-py3/jammy-updates,jammy-security,now 4.9.0-1ubuntu0.1 amd64 [installed]
Python 版本 3.10.12
我的apache文件conf etc/apache2/apache.conf(我在这里只添加了Servername和LimitRequestFieldSize)
ServerName caspian-bavarians.com
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
LimitRequestFieldSize 32768
我的网站conf文件
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName caspian-bavarians.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Alias /static /home/ftpuser/caspi/static
<Directory /home/ftpuser/caspi/static>
Require all granted
</Directory>
Alias /media /home/ftpuser/caspi/media
<Directory /home/ftpuser/caspi/media>
Require all granted
</Directory>
<Directory /home/ftpuser/caspi/main>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/ftpuser/caspi/main/wsgi.py
WSGIDaemonProcess django_app python-path=/home/ftpuser/caspi/ python-home=/home/ftpuser/venv
WSGIProcessGroup django_app
</VirtualHost>
Apache 错误日志
[周五 9 月 22 日 05:38:30.466675 2023][wsgi:错误][PID 6140:TID 140592497751616](70007)指定的超时已过期:[客户端 82.194.20.184:60468] mod_wsgi (pid=6140):无法代理来自守护程序的响应,referer:http://www.caspian-bavarians.com/az/cars/ [Fri Sep 22 05:38:34.918090 2023] [wsgi:error] [pid 6139:tid 140592497751616] [client 82.194.20.184:57353] 从守护进程“django_app”接收的截断或过大的响应标头:/home/ftpuser/caspi/main/wsgi.py,referer:http://www.caspian-bavarians.com/az/car/mercedes-benz-e220-7/[周五 9 月 22 日 05:38:34.918108 2023][wsgi:错误][PID 6139:TID 140592480966208][客户端 82.194.20.184:57024]从守护程序进程“django_app”接收的截断或过大的响应标头:/home/ftpuser/caspi/main/wsgi.py,referer:http://www.caspian-bavarians.com/az/cars/ [Fri Sep 22 05:50:33.804640 2023] [wsgi:error] [pid 6139:tid 140592298276416] (70007)指定的超时已过期:[客户端 82.194.20.184:63960] mod_wsgi (pid=6139):无法代理来自守护程序的响应 http://www.caspian-bavarians.com/az/cars/。[周五 9 月 22 日 05:50:37.371732 2023][wsgi:错误][PID 6139:TID 140592506144320][客户端 82.194.20.184:58025]从守护进程“django_app”读取响应标头时超时:/home/ftpuser/caspi/main/wsgi.py,referer:http://www.caspian-bavarians.com/az/car/mercedes-benz-e220-7/ [Fri Sep 22 05:50:38.194056 2023] [wsgi:error] [pid 6140:tid 140592323454528] [客户端 82.194.20.184:63962] 从守护进程“django_app”读取响应标头时超时:/home/ftpuser/caspi/main/wsgi.py,referer:http://www.caspian-bavarians.com/az/car/mercedes-benz-e220-7/[周五 9 月 22 日 05:50:38.742344 2023][wsgi:错误][PID 6139:TID 140592357025344][客户端 159.203.17.7:44390]从守护进程“django_app”接收的截断或过大的响应标头:/home/ftpuser/caspi/main/wsgi.py
我的 wsgi.py
"""
WSGI config for main project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
application = get_wsgi_application()
我的这个版本的应用程序在 heroku 上运行良好
- 我尝试了apt-get更新和升级
- 已检查 libapache-mod-wsqi-py3 的版本
- 已尝试重新启动系统
- 禁用,然后启用网站
答:
我找到了解决方案:将此行添加到您的apache配置文件中(在我的情况下,它是etc/apache2/apache.conf):
WSGIApplicationGroup %{GLOBAL}
上一个:错误消息“禁止您无权访问此资源”
评论