我有一个Django项目,显示根目录上的login视图。 这是url模式: url(r'^$', views.login_view, name="root_login") 这工作在一个未encryption的连接:当我在浏览器中访问http://example.com ,我得到我的login模板。 我最近使用letsencrypt在我的nginx代理上安装了SSL证书。 现在,当我尝试https://example.com我得到“Welcome to nginx!” 页。 当我使用不同的URL模式(例如, https://example.com/login )时,应用程序服务器按预期呈现视图。 实际上,除了根目录以外,所有的应用程序服务器视图都可以工 所以我猜我的location /上下文在我的SSL服务器块的nginxconfiguration是错误的,但我不明白在哪里,因为它是完全相同的location /上下文在我的未encryption的80端口块,它的工作原理。 这是整个SSL块 – 我的错误在哪里? server { #SSL connection listen 443; ssl on; server_name example.com; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_ciphers #omitted for brevity; ssl_session_timeout 1d; ssl_session_cache shared:SSL:1m; ssl_stapling on; ssl_stapling_verify […]
我正在用Python编写一个事件聚集服务器,使用Nginx + Gunicorn。 系统在1 cpu / 2核心盒(AWS c4.large)上的CPU最大值之前可以扩展到大约300 rps。 增加一个枪炮工或者使用小工,只能在利润率上(约10%)。 响应在1-2ms范围内(事件正被写入磁盘)。 从我的分析看来,gunicorn似乎花费了所有的时间和精力读取socket(在select()调用中是sync.py)。 与此同时,Nginx占据了CPU本身的2-3%左右。 使用UNIX套接字不会更改networking套接字上的性能configuration文件。 由于这些事件非常小(大约200字节),看起来它需要花费过多的努力才能将请求从套接字中取出。 我希望能够批量这些请求有效载荷之前,他们到达gunicorn,但我不知道如何做到这一点。 有什么办法可以减lessgunicorn正在采取的努力/ CPU的数量,并提高每箱的吞吐量?
我configuration了gunicorn.pyconfiguration文件来启动绑定到nginx的python服务器。 一切工作正常,除了启动服务。 我正在使用systemd Serviceconfiguration,这里是gunicorn服务: [Unit] Description = gunicorn daemon #Requires = gunicorn.socket After = network.target [Service] #PIDFile = /run/gunicorn.pid WorkingDirectory = /var/www/LTT/ltt Group = devs User = root Type = forking ExecStart = /usr/local/bin/gunicorn -c gunicorn.py app_ltt:app ExecReload = /bin/kill -s HUP $MAINPID ExecStop = /bin/kill -s TERM $MAINPID [Install] WantedBy = multi-user.target 在systemctl启动时尝试启动(但启用服务 ) […]
我在运行Django和Gunicorn(19.6.0)后面Nginx(1.6.2)。 一切工作正常,一个小问题。 如果我发送一个JSON有效负载大于10KB的POST请求和Django答复500er我在Chrome中得到一个net::ERR_INCOMPLETE_CHUNKED_ENCODING和响应是空的,虽然Django发送一个JSONstring{"error":"some error description"} 。 Nginx日志显示104: Connection reset by peer : 如果POST请求的有效负载很小,我会得到预期的结果。 如果我发送相同的请求(也与大有效载荷)直接gunicorn发生错误,我得到了预期的回应。 我的Nginxconfiguration: server { listen 80 default_server; server_name _; client_max_body_size 10m; location /static/ { root /srv/yyyyy; } location /media/ { root /srv/yyyyy; } # Proxy Pass to Gunicorn location / { include proxy_params; proxy_pass http://unix:/srv/yyyyy/proxy_pass.sock; } } 我也testing了一下proxy_buffering off; 在位置块,但仍然是相同的结果。
我想避免使用django和nginx不一致的错误页面。 如果一个静态文件没有find默认的nginx错误页面,而不是django的。 我认为这会导致性能不佳,将每个失败的请求redirect到gunicorn服务器,最终导致django错误页面。 我在哪里可以find默认的django错误页面,以及如何让nginx使用它们?
我正在build立一个ec2服务器,用ngnix和gunicorn来运行一个django项目。 服务器正在运行Amazon Linux。 当我从命令行运行启动gunicorn命令,它启动服务器,但是当我尝试从pipe理员运行它,我得到以下错误: supervisor: couldn't chdir to /home/ec2-user/virtualenvs/wakeup-site/django-site: EACCES supervisor: child process was not spawned 当我以sudo身份运行supervisor或者以我自己的用户身份运行时会发生这种情况 目录权限:/ home / ec2-user / virtualenvs / wakeup-site / django-site drwxrwxrwx 15 ec2-user ec2-user 4096 Mar 6 08:21 django-site 相关的Supervisor.conf文件: [program:wakeup] command=./start_gunicorn.bash directory="/home/ec2-user/virtualenvs/wakeup-site/django-site" user=ec2-user autostart=true autorestart=true stdout_logfile=/home/ec2-user/virtualenvs/wakeup-site/django-site/logs/supervisorconf.log stderr_logfile=/home/ec2-user/virtualenvs/wakeup-site/django-site/logs/gunicorn_stderr.log start_gunicorn.bash: #!/bin/bash # Starts the Gunicorn server set -e # […]
nginx版本:nginx / 1.9.3 gunicorn(版本19.7.1) 我有一个小型烧瓶API通过nginx后面的gunicorn运行。 当我通过gunicorn直接加载testing时,一切工作正常,但是一旦我将它指向nginx,我就会在nginx服务器上获得非常多的TIME_WAIT套接字。 Gunicorn框是好的。 这里是configuration: Gunicorn: bind = '0.0.0.0:7030' workers = 10 threads = 1 daemon = True DEBUG = "True" Nginx:相关的块: upstream api { keepalive 32; server box1:7030; server box2:7030; } server { listen 7077; server_name localhost; 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-Host $server_name; sendfile on; […]
我有一个非常基本的设置与nginx安装在运行在gunicorn服务器上的django应用程序。 gunicorn conf很简单,下面是: exec gunicorn myapp.wsgi:application \ –workers 5 –reload 我已经设置了nginx服务器,将默认服务器上的所有传入stream量proxy_pass设置为127.0.0.1:8000。 但是,当我到服务器的IP地址,我看到默认的nginx 404屏幕。 所以我假设stream量是由nginx服务器传递的代理,但不知何故没有正确路由,并没有回应,这迫使nginx返回404。我究竟是在这里做gunicorn或nginxconfiguration错误? 作为参考,下面是我的完整的nginx.conf文件: user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; […]
我需要在一个域的根目录build立一个Django站点,然后在一个子目录下(例如/ blog /)安装一个Wordpress。 如何configurationNGinX来做到这一点? “漂亮”的url也必须适用于WordPress。 对于Django,我正在使用已configuration好的Gunicorn。 从NGinX我会打电话给“proxy_pass”来指导。 PHP通过FPM运行。 考虑到上面的限制,我将如何configurationNGinX? 任何帮助,将不胜感激! 谢谢。 更新:我已经尝试了几件事情,目前我有一部分工作。 我已经删除了任何Djangoconfiguration。 然后我在/ blog /子目录中find了WordPress。 在那里,我有test.php,它只是调用phpinfo(),然后test.html,它显示纯净的HTML。 当调用test.php时,页面加载。 但是,当我打电话test.html,或index.php(Wordpress索引页),它给了我一个404。 我的nGinxconfiguration: server { listen 80; root /path/to/www/root; server_name domain.com; access_log /path/to/logs/access.log; error_log /path/to/logs/error.log; location / { index index.php; } location /blog { alias /path/to/www/blog; try_files $uri =404; index index.php index.html; } location ~ /blog/.+\.php$ { include […]
我一直在对后端架构进行大量的研究。 我目前在亚马逊的Web服务上运行django应用服务器和postgresql数据库服务器。 我所有的内容都是通过Gunicorn服务的。 我想知道为什么nginx服务器放在django应用服务器的前面。 他们的目的是什么? 这是一张图表: https://d36cz9buwru1tt.cloudfront.net/architecture_diagram_praekelt-1.jpg