我试图让升级后的服务器恢复在线状态,我不能再让Nginx直接调用Gunicorn了 – 我发送给网站的每个请求都会返回一个502 Bad Gateway 。 我在端口8001上运行gunicorn_django (从ps aux | grep gunicorn可以看到 – 两个worker的命令的参数是-b 0.0.0.0:8001 。我的Nginxconfiguration在我的唯一configurationsites-enabled : upstream django_test { server 127.0.0.1:8001; } …所以它应该是要求那里。 自升级以来,这个configuration文件没有任何改变。 当我在浏览器中访问mysite.com/robots.txt时,会返回我在sites-enabled了sites-enabledconfiguration中定义的robots.txt ,因此文件肯定会被加载。 此外,当我从服务器运行curl 127.0.0.1我仍然得到502 bad gateway 。 有谁知道这里会发生什么?
我有一台运行在Gunicorn和Nginx之上的Django服务器,昨天晚上我经历了一小段时间的停机。 重新启动Nginx和Gunicorn后,服务器恢复正常,但我无法弄清楚是什么导致了中断。 检查日志概述了问题发生的地方:首先,大约有100行: 2014/03/04 15:48:47 [emerg] 21790#0: *19536658 posix_memalign(16, 4096) failed (12: Cannot allocate memory), client: xx.xx.xx.xx, server: www.mysite.com, request: "GET /static/images/loading.gif HTTP/1.1", host: "www.mysite.com" 然后,实际的错误来了。 这其中约有300个: 2014/03/04 15:49:04 [error] 21790#0: *19532341 connect() failed (110: Connection timed out) while connecting to upstream, client: xx.xx.xx.xx, server: www.mysite.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "www.mysite.com" …和其中约100个: […]
我在当前的设置中使用loadbalancer,请求来自IP 10.71.128.13 。 我使用Nginx作为Gunicorn后端的前端。 我想获得访问者的真实IP地址并logging它(而不是负载均衡IP)。 我的nginx.conf: log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; # GET REAL IP set_real_ip_from 10.71.128.12; set_real_ip_from 10.71.128.13; set_real_ip_from 10.71.128.14; real_ip_header X-Forwarded-For; 我的服务器块'example.conf' # HTTPS server { etc…. location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header Host $http_host; proxy_redirect off; proxy_buffering on; } […]
情况 我为我的移动应用程序创build了一个REST API,现在我想创build一个网站。 API到目前为止非常简单,只是为了“获取内容列表”,“更新数据库中的某个字段”等几个请求。但现在,我想创build一个网站,当然会使用相同的数据库。 我不认为这个API将在网站项目中有用。 题 把API和网站分开保存,在两个不同的实例上更好一些,还是最好把它合并起来? 例如, api.example.com上的API地址为127.0.0.1:8001网站地址为127.0.0.1:8002 ,当然还有两个不同的nginx服务器configuration(如果仍然存在不知道我的意思是:P)? 或者在处理请求方面的performance并不重要,最好是通过链接example.com/api/…完成一个项目。
我目前正在设置nginx + gunicorn来服务一个django应用程序,这个应用程序将被最多60个用户使用。 该应用程序是非常基本的,6个Django表格由10个字段和10个报告页面提交的答案。 以及以csv格式导出响应的能力。 使用本教程中提供的默认configuration,使用3名worker的gunicorn,并使用postgresql默认configuration,而不进行任何调整,系统可以处理多less个并发用户? 我一直在试图用围攻来模拟并发用户,但我不确定这是否是检查并发用户的正确方法。 是否还有其他工具可用来更好地了解有多less用户可以处理?
我正在用Debian Jessie和Django 1.8一起工作,试图build立Gunicorn来运行我的Django站点。 我build立了一个名为opuser的用户,并且让这个用户成为gunicorn.sock文件和包含目录的所有者: $ ls -lash /webapps/myapp/run/ total 8.0K 4.0K drwxrwxrwx 2 opuser users 4.0K Sep 1 12:24 . 4.0K drwxrwxrwx+ 7 opuser users 4.0K Sep 1 10:37 .. 现在,如果我试图运行gunicorn作为opuser : gunicorn myapp.wsgi:application –name myapp_prod –workers 3 –bind=unix:/webapps/myapp/run/gunicorn.sock –user opuser –group webapps –log-level=debug 我得到: OSError: [Errno 13] Permission denied: '/webapps/myapp/run/gunicorn.sock' 当opuser是包含目录的所有者时,为什么我得到权限被拒绝? 如果我运行ls -lash /webapps/myapp/run再次ls […]
我有两个实例在Ubuntu 12.04上运行在相同的Azure VM服务器上。 Azure在默认情况下给我提供了PUBLIC VIRTUAL IP (VIP) ADDRESS和INTERNAL IP ADDRESS所以configurationpassproxy并不是那么明显。 我的例子是: Nginx + Gunicorn(Main,Django App)在端口内部端口8080(80为公共IP) Nginx + Apache(第二个)在内部端口5050(公众5000) 我想从实例2看起来像第一个有限的页面数量。 例如,页面my_public_ip:5000/data应该看起来像my_public_ip/data 。 同时一次应该服务所有其他页面。 你能帮我吗? 我目前的第一个例子NGINX conf: server { listen 8080; server_name my_internal_ip; port_in_redirect off; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/path/to/static; } location / { include proxy_params; proxy_pass http://unix:/home/path/to/gunicorn.sock; […]
我想在我的Django服务器上用gunicorn和Nginx运行主pipe,但是当我运行“supervisord”时,主pipe日志说: 2015-11-06 23:23:36,746 INFO daemonizing the supervisord process 2015-11-06 23:23:36,749 INFO supervisord started with pid 13766 2015-11-06 23:23:37,758 INFO spawned: 'gunicorn' with pid 13773 2015-11-06 23:23:37,767 INFO exited: gunicorn (exit status 127; not expected) 2015-11-06 23:23:38,771 INFO spawned: 'gunicorn' with pid 13774 2015-11-06 23:23:38,802 INFO exited: gunicorn (exit status 127; not expected) 2015-11-06 23:23:40,807 INFO […]
我想为nginx设置ssl,我的项目是django,我也使用gunicorn作为wsgi http服务器。 我在settings.py代码中添加以下几行代码: CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True 我不知道是否有必要这样做,然后我configuration我的nginx在以下forms: server { listen 80; server_name <name>; return 301 https://$host$request_uri; } server { #listen 80; listen 443 default ssl; client_max_body_size 4G; server_name <name>; #ssl on; ssl_certificate /etc/nginx/ssl/ssl.crt; ssl_certificate_key /etc/nginx/ssl/ssl.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; keepalive_timeout 5; # path for static files […]
我一直在Django Cookie Cutter的地方项目中玩耍,想把它作为一个半生产阶段环境放在我的DO Droplet上。 服务器设置Nginx的反向代理到各种项目,一些服务与Gunicorn,一个裸瓶,一个与uWSGI。 每个项目都有自己的virtualenv。 在部署这个项目并进行设置时,我有以下一系列的错误。 Nginx的conf如下(这反映在这个液滴上的其他网站): server { server_name test.myserver.com; access_log off; location /static/ { alias /var/www/myproject/static/; } location / { proxy_pass http://127.0.0.1:8085; 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后,这个“工作”/做我所期望的:抛出一个502错误的网关错误和nginx日志注意: 2016/02/25 11:27:25 [error] 21217#0: *275 connect() failed (111: […]