请解释使用不同 Nginx WSGI 接口时的优缺点?请详细说明每种配置的区别是什么?哪种配置的扩展性最好?
如果相关,您现在正在运行什么,为什么?
我见过的一些技巧,但请告诉我是否遗漏了任何技巧:
我正在尝试在我的 Mac OS X 10.7 lion 上设置石墨,我已经设置了 apache 以通过 WSGI 调用 python 石墨脚本,但是当我尝试访问它时,我从 apache 和错误日志中得到一个禁止.
"client denied by server configuration: /opt/graphite/webapp/graphite.wsgi"
Run Code Online (Sandbox Code Playgroud)
我已经检查了 httpd.conf 中允许的脚本位置以及文件的权限,但它们似乎是正确的。我需要做什么才能获得访问权限。下面是 httpd.conf,它几乎是石墨示例。
<IfModule !wsgi_module.c>
LoadModule wsgi_module modules/mod_wsgi.so
</IfModule>
WSGISocketPrefix /usr/local/apache/run/wigs
<VirtualHost _default_:*>
ServerName graphite
DocumentRoot "/opt/graphite/webapp"
ErrorLog /opt/graphite/storage/log/webapp/error.log
CustomLog /opt/graphite/storage/log/webapp/access.log common
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
# XXX You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照本教程uWSGI使用Django和nginxon进行设置Ubuntu16.04。
一切正常,直到我尝试执行此命令的最后一步(哦,讽刺的是...):
sudo service uwsgi start
Run Code Online (Sandbox Code Playgroud)
如果失败并出现以下错误:
启动 uwsgi.service 失败:未找到单元 uwsgi.service。
其他人似乎得到了类似的错误:
启动 uwsgi.service 失败:单元 uwsgi.service 加载失败:没有这样的文件或目录。
该问题似乎与 Ubuntu 的版本有关。虽然该教程针对的是 Ubuntu 14.04,但它似乎不适用于较新的版本,因为在 15 版中 Ubuntu 从upstartinit daemon切换到systemdinit daemon。
如何使用systemduWSGI 启动 uWSGI 以便它与 nginx 和 Django 一起使用?
我已经搜索了整个文件以寻找放置指令的位置,但我不知道将它放在哪里,而且互联网似乎也没有很好的答案,或者我可能只是不擅长搜索它呵呵。
有人知道这个指令要放在哪里吗?
我有一个自定义的 Django 应用程序,大约每 5,000 个请求就会变得无响应。在 apache 日志中,我看到以下内容:
Apr 13 11:45:07 www3 apache2[27590]: **successful view render here**
...
Apr 13 11:47:11 www3 apache2[24032]: [error] server is within MinSpareThreads of MaxClients, consider raising the MaxClients setting
Apr 13 11:47:43 www3 apache2[24032]: [error] server reached MaxClients setting, consider raising the MaxClients setting
...
Apr 13 11:50:34 www3 apache2[27617]: [error] [client 10.177.0.204] Script timed out before returning headers: django.wsgi
(repeated 100 times, exactly)
Run Code Online (Sandbox Code Playgroud)
我相信我正在使用以下配置运行 WSGI 2.6 (/usr/lib/apache2/modules/mod_wsgi.so-2.6):
阿帕奇配置
WSGIDaemonProcess site-1 user=django group=django threads=50
WSGIProcessGroup …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的本地 ubuntu 机器上使用 django 应用程序。但是,该站点无法正常工作,并且我的站点中/var/log/apache2/errors.log充满了如下消息:
ImportError: No module named site
Run Code Online (Sandbox Code Playgroud)
我的/var/log/apache2/error.log(今天)看起来像这样:
$ cat error.log | uniq -c
1 [Wed Jun 29 09:37:37 2011] [notice] Apache/2.2.17 (Ubuntu) mod_wsgi/3.3 Python/2.7.1+ configured -- resuming normal operations
12966 ImportError: No module named site
Run Code Online (Sandbox Code Playgroud)
这是当我打开机器时它启动的通知,然后是 12,966 行都在说no module named site消息
请注意缺少日期时间字段。即使不访问网站(即,即使不发出网络请求),也会重复这些错误。在浏览器中访问网站时,它只是挂起,好像在等待大量下载。
我正在使用 python 2.5 virtualenv,其中安装了很多包(包括 django 1.1)和 pip。我已经加载了 mod_wsgi:
$ ls -l /etc/apache2/mods-enabled/wsgi*
lrwxrwxrwx 1 root root 27 2010-10-04 16:50 /etc/apache2/mods-enabled/wsgi.conf -> ../mods-available/wsgi.conf
lrwxrwxrwx 1 root …Run Code Online (Sandbox Code Playgroud) 在这些配置了 django、gunicorn、supervisor 和 nginx 的服务器上运行非常高的流量。但很多时候我往往会看到 502 错误。所以我检查了 nginx 日志以查看什么错误,这是记录的内容:
[错误] 2388#0:*208027 connect() to unix:/tmp/gunicorn-ourapp.socket 在连接到上游时失败(11:资源暂时不可用)
任何人都可以帮助调试可能导致这种情况发生的原因吗?
这是我们的 nginx 配置:
sendfile on;
tcp_nopush on;
tcp_nodelay off;
listen 80 default_server;
server_name imp.ourapp.com;
access_log /mnt/ebs/nginx-log/ourapp-access.log;
error_log /mnt/ebs/nginx-log/ourapp-error.log;
charset utf-8;
keepalive_timeout 60;
client_max_body_size 8m;
gzip_types text/plain text/xml text/css application/javascript application/x-javascript application/json;
location / {
proxy_pass http://unix:/tmp/gunicorn-ourapp.socket;
proxy_pass_request_headers on;
proxy_read_timeout 600s;
proxy_connect_timeout 600s;
proxy_redirect http://localhost/ http://imp.ourapp.com/;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $my_scheme;
#proxy_set_header X-Forwarded-Ssl $my_ssl;
}
Run Code Online (Sandbox Code Playgroud)
我们已经将 Django 配置为在 …
我使用 Nginx 作为使用 HTTP 身份验证的 Apache 服务器的反向代理。出于某种原因,我无法将 HTTP_AUTHORIZATION 标头传递给 Apache,它似乎被 Nginx 过滤掉了。因此,没有请求可以进行身份验证。
请注意,基本身份验证是动态的,因此我不想在我的 nginx 配置中对其进行硬编码。
我的 nginx 配置是:
server {
listen 80;
server_name example.co.uk ;
access_log /var/log/nginx/access.cdk-dev.tangentlabs.co.uk.log;
gzip on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 120;
location / {
proxy_pass http://localhost:81/;
}
location ~* \.(jpg|png|gif|jpeg|js|css|mp3|wav|swf|mov|doc|xls|ppt|docx|pptx|xlsx|swf)$ {
if (!-f $request_filename) {
break;
proxy_pass http://localhost:81;
}
root /var/www/example;
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样?
更新- 原来这个问题是我在我的原始问题中忽略的:mod_wsgi。这里有问题的站点是一个 Django 站点,事实证明 Apache 确实通过了 auth 变量,但是 mod_wsgi 将它们过滤掉了。
决议是使用:
WSGIPassAuthorization On
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请参阅http://www.arnebrodowski.de/blog/508-Django,-mod_wsgi-and-HTTP-Authentication.html
使用 uWSGI 来提供一个简单的 wsgi 应用程序(一个简单的“Hello, World”)我的配置有效,但是当我尝试运行一个 Flask 应用程序时,我在 uWSGI 的错误日志中得到了这个:
current working directory: /opt/python-env/coefficient/lib/python2.6/site-packages
writing pidfile to /var/run/uwsgi.pid
detected binary path: /opt/uwsgi/uwsgi
setuid() to 497
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.6.6 (r266:84292, Jun 18 2012, 14:18:47) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)]
Set PythonHome to /opt/python-env/coefficient/
*** Python threads support is disabled. You can enable …Run Code Online (Sandbox Code Playgroud) 为了支持自动 LetsEncrypt 证书续订,certbot 使用--apache处理程序。
例如
certbot renew --apache
Run Code Online (Sandbox Code Playgroud)
该处理程序在 Apache 服务器上为*/.well-known/acme-challenge/安装一个临时 VirtualHost ,以验证续订。
问题是,如果现有虚拟服务器使用安装在 http 服务器根目录上的 HTTPS 和 Django over WSGI,则此机制不起作用。
临时 VirtualHost 无法捕获 URL,因此 Django 尝试为请求提供服务(但失败),因为该 URL 不在其 URL 列表中。
wsgi ×10
django ×6
nginx ×4
python ×3
apache-2.2 ×2
mod-wsgi ×2
uwsgi ×2
apache2 ×1
fastcgi ×1
graphite ×1
gunicorn ×1
httpd.conf ×1
lets-encrypt ×1
linux ×1
ubuntu ×1
web-server ×1