Articles of gunicorn

nginxredirectip到域名

我想用nginx和gunicorn部署一个网站。 Nginx正在提供静态文件,并作为gunicorn的代理。 这里是我的/ etc / nginx / sites-available / herbop文件的内容 server { listen 80; server_name herbop.com; location / { 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 $scheme; proxy_set_header Host $http_host; proxy_intercept_errors on; proxy_pass http://127.0.0.1:8001; } location /static/ { autoindex on; alias /opt/Herbop-Backend/app/static/; } } server { listen 80; server_name 51.254.123.234; return 301 $scheme://herbop.com$request_uri; } […]

Nginx的连接()失败(111:连接被拒绝),同时连接到上游

我运行的网站使用Django,Nginx,Gunicorn,Supervisord和fail2ban(只允许ssh,http和https)。 该网站是生活和正常工作,但有一些nginx错误日志条目涉及: connect() failed (111: Connection refused) while connecting to upstream, client: xxxx, server: www.example.com, request: "GET /example/url/to/get/ HTTP/1.1", upstream: "http://[::1]:8000/example/url/to/get/", host: "www.example.com" upstream server temporarily disabled while connecting to upstream, client: xxxx, server: www.example.com, request: "GET /example/url/to/get/ HTTP/1.1", upstream: "http://[::1]:8000/example/url/to/get/", host: "www.example.com" 这是我的nginxconfiguration: upstream app_server_wsgiapp { server localhost:8000 fail_timeout=0; } server { listen 80; […]

Django无法find由nginx提供的静态文件

我知道这是一个非常不好的问题,但我找不到任何解决scheme,尽pipe发现问题微不足道。 我有一个Django应用程序与gunicorn部署。 nginx服务器使用以下URL提供静态文件: myserver.com/static/admin/css/base.css 。 然而,我的django应用程序继续寻找在myserver.com:8001/static/admin/css/base.css的静态文件,显然是失败的(404)。 我不知道如何解决这个问题。 这是一个Django的或Nginx的问题? 这是我的nginxconfiguration文件: server { server_name myserver.com; access_log off; location /static/ { alias /home/myproject/static/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } 谢谢您的帮助 !

使用Nginx,Gunicorn,Django运行论坛需要多less内存?

我开始了一个ec2实例(微型)来testing我可用来运行一个网站的内存量,但我期待有更多。 所以我的问题是:我需要多lessRAM来运行使用Django,Nginx和Gunicorn的站点。 这是我发现的: 启动Ubuntu 12.04实例将消耗: total used free shared buffers cached Mem: 590 235 354 0 7 182 -/+ buffers/cache: 45 544 Swap: 0 0 0 运行Gunicorn后: total used free shared buffers cached Mem: 590 195 394 0 9 73 -/+ buffers/cache: 112 477 Swap: 0 0 0 所以我有394MB可用,虽然我忘了创build交换卷。 足够运行每月接收3000-4000次访问的论坛吗? 我也将赞赏一些正确的方式来configuration交换的意见。 非常感谢

服务器重启后无法通过Supervisor启动Gunicorn

我有一个使用Nginx和Gunicorn的Django应用程序“djngxgun”。 我只是安装了主pipe,以便我可以使用它来pipe理我的Gunicorn进程。 问题是Supervisor在重新启动服务器后没有启动Gunicorn。 当我通过Supervisor启动Gunicorn(“sudo supervisorctl start djngxgun”)时,我看到在我的Gunicorn error.log文件中重复出现以下错误: 2014-02-28 15:36:47 [4753] [INFO] Starting gunicorn 18.0 Traceback (most recent call last): File "/home/djngxgun/venv/djngxgun/bin/gunicorn", line 9, in <module> load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')() File "/home/djngxgun/venv/djngxgun/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() File "/home/djngxgun/venv/djngxgun/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run Arbiter(self).run() File "/home/djngxgun/venv/djngxgun/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 172, in run self.start() File "/home/djngxgun/venv/djngxgun/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line […]

压力testingDjango应用程序 – 如何提高吞吐量?

我第一次尝试压力testing一个简单的django web应用程序,运行在gunicorn和nginx上,我把它放在一个小型的256MB Rackspace Cloud服务器上。 使用httperf,我增加每秒的连接数,直到我开始得到错误例如 httperf –hog –server=localhost –uri=/myapp –timeout=10 –num-conns=2500 –rate=25 我发现,从Django几乎静态页面,我可以得到约35 req /秒之前,错误开始被抛出。 对于需要数据库查询和更多处理的更加dynamic的页面,我可以获得大约25次/秒。 最初我只使用1个gunicorn worker,但增加到4个worker(我认为我的云服务器有4个内核)似乎没有任何区别(它仍然开始抛出25 req / sec以上的错误)。 这些结果听起来像预期的一样,考虑到这是一个如此小(256MB)的服务器上运行? 另外,是否有任何改变,我可以提高吞吐量?

Nginx> Varnish> Gunicorn Error太多的redirect

我有以下configuration: Nginx>清漆> Gunicorn> Django 我想caching与同一个网站(移动和networking)的2个版本与清漆。 Gunicorn: WEB: gunicorn_django –bind 127.0.0.1:8181 MOBILE: gunicorn_django –bind 127.0.0.1:8182 Nginx的: WEB: server { listen 80; server_name www.mysite.com; location / { proxy_pass http://127.0.0.1:8282; # pass to Varnish proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 移动: server { listen 80; server_name m.mysite.com; location / { proxy_pass http://127.0.0.1:8282; # […]

通过Nginx和proxy_pass上传到Gunicorn的文件很慢(Ubuntu 14)

我以前运行的是Ubuntu 12,我有Nginx接收大file upload,然后proxy_pass到gunicorn / django(端口8000)。 一旦我想出我需要设置client_max_body_size 300M;这工作得很好。 这个环境是用stream浪汉和厨师创造的。 但是,一旦升级到Ubuntu 14,我发现上传速度非常慢。 10M的文件需要几分钟的时间(文件的3%每10秒上传一次)。 我看着越来越多的代理传递缓冲区和其他客户端缓冲区大小,但无济于事。 是否有更改从U12到U14的基本参数可能会导致此问题?

Nginx和gunicorn不显示整个页面(caching问题)

我有一个Django的应用程序,它在Django的服务器上工作正常。 我只是configuration它与nginx和gunicorn。 除了其中一个外,几乎每个页面都可以正常工作。 这是一个非常大的页面,它由4个select(下拉)菜单组成,每个菜单1000个条目,每个菜单由guinicorn单个html文件发送。 Gunicorn只显示页面的一半。 有趣的是,没有nginx,gunicorn显示整个事情就好了。 尽pipe生成的页面不是静态的,但由于某种原因,nginx会中断页面​​。 这是我的nginxconfiguration: ec2-user@ip-172-31-44-39:~/mira_website> sudo cat /etc/nginx/sites-available/miraFrontEnd # This is example contains the bare minimum to get nginx going with # Gunicornservers. worker_processes 1; user ec2-user nogroup; # for systems with a "nogroup" # user nobody nobody; # for systems with "nobody" as a group instead # Feel free to […]

什么是正确的方式来承载不同的Django应用程序作为nginx位置

我有一个静态网站(www.example.com)和一个运行在单台服务器(机器1)上的Django应用程序(example.com/app1)。 网站和应用程序都使用nginx服务。 我正在使用gunicorn服务Django应用程序。 机器1上的nginxconfiguration如下所示: upstream gunicorn { server 127.0.0.1:8000; # gunicorn serving App1 } server { listen 80 default_server; listen [::]:80 default_server; server_name example.com www.example.com; root /var/www/example; index index.html index.htm index.nginx-debian.html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. # try_files […]