Articles of uwsgi

nginxconfigurationuwsgi和gzip缓冲区以适应不同的使用场景

我试图为nginx中相对不同的使用场景和资源消耗configuration两个URLpath组。 两者都由相同的uwsgi应用程序服务。 第1组:常规HTML页面大小为128k,默认为cca 第2组:大型XML“文件”,大小可达多MB(由应用程序即时创build) 这个要求是要被压缩,并且XML也应该被caching1个小时。 我不太明白的是缓冲区数量的含义,以及如何根据预期的stream量和内容大小来优化设置它们的数量和大小,无论是uwsgi还是gzip。 另外,对于下面的configuration,我从nginx得到错误: "uwsgi_busy_buffers_size" must be less than the size of all "uwsgi_buffers" minus one buffer in /etc/nginx/nginx.conf:113 uwsgi_busy_buffers_size似乎没有logging。 location ~ /path/to/(.+)\.xml { uwsgi_hide_header "Set-Cookie"; uwsgi_ignore_headers "Set-Cookie"; uwsgi_buffers 2 8M; uwsgi_cache xmlfiles; uwsgi_cache_key $request_uri; uwsgi_cache_valid 200 1h; uwsgi_cache_valid 04 5m; uwsgi_cache_use_stale error; expires +1h; gzip on; gzip_types application/xml; gzip_buffers 2 8M; […]

UWSGI –cheap和–idle模式 – 预期的行为

我使用以下命令在uwsgi上运行django uwsgi –master –cheap –idle 60 –http-socket :8084 –wsgi-file /var/django/mysite/django.wsgi 通常我的stream程每个都在10MB左右,但我看到他们坐在大约半个MB的位置。 我的问题是,当服务器内存不足时,uwsgi是否会将进程降低到更便宜的模式? 如果任何人都可以解释如何–cheap和–idle的工作,那将不胜感激。

Nginx的HTTP / HTTPS – Http似乎redirect到HTTPS的所有的时间

我用我的ubuntu 10.04 / nginx 1.2.3服务器,这真的很奇怪的行为。 基本上我今天早上更改了SSL证书。 从那以后,它在所有的应用程序上都performance得很怪异。 Godaddy报告说HTTPS / SSL设置是正确的。 当我尝试一个页面时,它仍然正常工作,当我使用HTTPS。 但是当我尝试使用HTTP nginx报告错误: 400 Bad Request The plain HTTP request was sent to HTTPS port 经过几个小时在谷歌环顾四周,我已经尝试了不同的设置(原来我的设置长时间工作正常,我只是更新证书) 我发现一半的解决scheme添加到我的configuration: error_page 497 $ request_uri; 真正奇怪的是,当我使用这个设置: server { listen 80; server_name john.johnrocks.eu; access_log /home/john/envs/john_prod/nginx_access.log; error_log /home/john/envs/john_prod/nginx_error.log; location / { uwsgi_pass unix:///home/john/envs/john_prod/john.sock; include uwsgi_params; } location /media { alias /home/john/envs/john_prod/johntab/www; […]

重新启动nginx后端而不会丢失请求

我确定以前用过不同的语言,但是我通过nginx后面的uwsgi(emporer模式)运行了几个Django站点。 这是一个相当标准的configuration,但我发现,如果我重新启动中央uwsgi进程,nginx只是炸弹了502s,而不是等待套接字变得可用。 我承认这其中的大部分可能是有原因的,但是看到502错误的人确实会刺痛我。 这当然不是我想让客户看到的东西。 所以… 我可以求nginx等待/重试后端? 要么, 有什么(除了明显的)我可以做到最小化从uwsgi重新启动的商业损失?

如何使用uWSGI将环境variables传递给WSGI脚本?

我已经将以下行添加到/etc/environment : FOO_DEPLOYMENT_ENV="vbox" 通过SSHlogin后,我可以echo $FOO_DEPLOYMENT_ENV ,当然,也可以将vbox输出到shell。 如果我打开一个Python shell并运行os.getenv('FOO_DEPLOYMENT_ENV') ,它将返回'vbox' ,但是在我的Python应用程序中,当它由uWSGI(如www-data用户)运行时,它看不到相同的代码环境variables。 显然,这不是uWSGI的问题,而是我对环境variables的理解,或者它们是如何正确设置的,以及它们可以被检索的上下文的问题。 我在做什么或理解不正确?

Uwsgi从根开始,但不作为服务

我有nginx + uwsgi设置烧瓶网站。 那是我的nginx server { listen 80; server_name _; location /static/ { alias /var/www/site/app/static/; } location / { uwsgi_pass 127.0.0.1:5080; include uwsgi_params; } } 这是我的uwsgi config.xml <uwsgi> <socket>127.0.0.1:5080</socket> <autoload/> <daemonize>/var/log/uwsgi_webapp.log</daemonize> <pythonpath>/var/www/site/</pythonpath> <module>run:app</module> <plugins>python27</plugins> <virtualenv>/var/www/venv/</virtualenv> <processes>1</processes> <enable-threads/> <master /> <harakiri>60</harakiri> <max-requests>2000</max-requests> <limit-as>512</limit-as> <reload-on-as>256</reload-on-as> <reload-on-rss>192</reload-on-rss> <no-orphans/> <vacuum/> </uwsgi> 当我试图启动uwsgi服务( service uwsgi start )它说好,但没有uwsgi进程,我在日志中看到以下内容: *** Starting uWSGI […]

Nginx + uwsgi … 502坏的网关

所以我试图用我的Django应用程序的uwsgi设置Nginx。 这是我的/etc/nginx/nginx.conf文件: # /etc/nginx/nginx.conf user richard richard; ## Default: nobody worker_processes 5; ## Default: 1 error_log /var/log/nginx/error.log; pid /var/log/nginx/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; ## Default: 1024 } http { include /etc/nginx/mime.types; include /etc/nginx/proxy.conf; index index.html index.htm; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log […]

Uwsgiconfiguration – 没有模块叫做网站

我正在试图让uwsgi与nginx结合使用来作为烧瓶应用程序。 这是UWSGI ini文件: [uwsgi] socket = 127.0.0.1:8001 processes = 4 module = run:manager virtualenv = /var/www/test/venv chdir = /var/www/test logto = uwsgi.log 在目录/ var / www / test中我有这个文件run.py from flask.ext.migrate import Migrate, MigrateCommand from flask.ext.script import Manager from app import app, db if __name__ == "__main__": migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) […]

Arch Linux上的uWSGI和Python,编码失败

我正在运行一个Arch Linux框,并设置了一个Python 3.4 virtualenv。 我有一个由皇帝pipe理的uwsgi封臣,它指定了以下ini:(为了简洁, [uwsgi] virtualenv = /opt/lib/virtualenvs/bartek socket = /tmp/bartek.sock module = app callable = app plugins = python 当我运行这个并查看uwsgi日志文件,我一直得到这个: uwsgi socket 0 bound to UNIX address /tmp/bartek.sock fd 3 Python version: 3.4.1 (default, May 19 2014, 17:23:49) [GCC 4.9.0 20140507 (prerelease)] Set PythonHome to /opt/lib/virtualenvs/bartek Fatal Python error: Py_Initialize: Unable to get […]

使用Nginx的uwsgiconfiguration,使用python脚本作为cgi-502 Bad Gateway

这是我的.ini文件来运行uwsgi“pyApp.py” [uwsgi] plugins = cgi socket = 127.0.0.1:9010 cgi = /=/usr/share/test/ cgi-allowed-ext = .py cgi-helper = .py=python 我在位置/usr/share/test/firstapp.py有一个“firstapp.py”文件它的内容是 #!/usr/bin/python print "Content-type: text/html\n\n" print "<html><body><h1>It works! Cool!!</h1></body></html>" 我正在用命令运行uwsgi的实例 uwsgi –http :9011 –http-modifier1 9 –ini pyApp.ini –master 我已经使用nginxconfiguration了几个虚拟主机。 而其中的一个必须指向/ usr / share / test /目录,当其中有“/ cgi-bin /”的url时。 nginxconfiguration是 – [也是唯一默认的] server { listen 80 default_server; listen [::]:80 […]