在具有多个虚拟主机的nginx服务器之前清除服务器

我试图寻找一个这样的解决scheme,但不能find任何文档/提示我的具体设置。

我的设置:

后端服务器:ngnix:virtualenv中运行gunicorn / python / django的2个不同网站(2个顶级域名)后端服务器硬件(VPS)2gb ram,8个CPU

数据库服务器:postgresql – pg_bouncer
后端服务器硬件(VPS)1GB RAM,8个CPU

清漆服务器:只运行清漆
Varnishserver硬件(VPS)1GB内存,8个CPU

我试图build立一个清漆服务器来处理罕见的stream量高峰(20 000个唯一请求/秒)当电视节目提到其中一个网站时,就会发生峰值。

我需要做些什么,使清漆服务器caching我的后端服务器上的两个网站/域?

我的/etc/varnish/default.vcl:

backend django_backend { .host = "local.backendserver.com"; .port = "8080"; } 

我的/usr/local/nginx/site-avaible/domain1.com

 upstream gunicorn_domain1 { server unix:/home/<USER>/.virtualenvs/<DOMAIN1>/<APP1>/run/gunicorn.sock fail_timeout=0; } server { listen 80; listen 8080; server_name domain1.com; rewrite ^ http://www.domains.com$request_uri? permanent; } server { listen 80 default_server; listen 8080; client_max_body_size 4G; server_name www.domain1.com; keepalive_timeout 5; # path for static files root /home/<USER>/<APP>-media/; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://gunicorn_domain1; break; } } } 

我的/usr/local/nginx/site-avaible/domain2.com

 upstream gunicorn_domain2 { server unix:/home/<USER>/.virtualenvs/<DOMAIN2>/<APP2>/run/gunicorn.sock fail_timeout=0; } server { listen 80; listen 8080; server_name domain2.com; rewrite ^ http://www.domains.com$request_uri? permanent; } server { listen 80; listen 8080; client_max_body_size 4G; server_name www.domain2.com; keepalive_timeout 5; # path for static files root /home/<USER>/<APP>-media/; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://gunicorn_domain2; break; } } } 

现在,如果我尝试清漆服务器的IP,我只能服务于domain1.com。 如果我将两个域的DNS更改为指向varnishserver,或者是否有额外的设置,那么一切都会正确吗?

问题2:我需要一个专门的清漆服务器,还是只在我的后端服务器上安装清漆,还是服务器内存快用完?