简体   繁体   English

如何配置Nginx> Varnish> uWSGI设置

[英]How to configure an Nginx > Varnish > uWSGI setup

I found this example http://projects.unbit.it/uwsgi/wiki/Example (see: Varnish and nginx, the best way (0.9.8.4)) which suggests putting Varnish between Nginx and uWsgi. 我在http://projects.unbit.it/uwsgi/wiki/Example中找到了这个示例(请参阅:Varnish和nginx,最好的方法(0.9.8.4)),该示例建议将Varnish放在Nginx和uWsgi之间。

I'm trying to get this working for my Django site. 我正在尝试让它在我的Django网站上正常工作。

It's all running but when I use varnishlog, I don't see anything showing up when visiting my site. 它全部都在运行,但是当我使用varnishlog时,访问我的网站时看不到任何内容。 It seems that varnish is not doing much. 看来清漆作用不大。

My configuration is: 我的配置是:

Nginx: (replaced real domainname with 'domain') Nginx :(将真实域名替换为“ domain”)

upstream uwsgi_staging {
    server 127.0.0.1:3031;
}


server {
    listen 80;
    server_name domain.com;

    root /var/www/domain/staging/src/;

    location / {
        uwsgi_pass uwsgi_staging;
        include uwsgi_params;
    }
}

uWSGI: (relevant part of .ini conf file used by emperor process) uWSGI :(皇帝进程使用的.ini conf文件的相关部分)

socket = 127.0.0.1:3031
protocol = http
module = website.wsgi:application

Varnish: 漆:

/etc/default/varnish 在/ etc /默认/清漆

DAEMON_OPTS="-a :6081 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"

/etc/varnish/default.vcl /etc/varnish/default.vcl

backend uwsgi {
    .host = "127.0.0.1";
    .port = "3031";
}


sub vcl_recv {    
    set req.backend = uwsgi;
}

Varnish is only serving cached responses to requests without any cookies set. Varnish仅提供对请求的缓存响应,而未设置任何cookie。 You need to make sure to unset unnecessary cookies to unleash the full power of varnish. 您需要确保取消设置不必要的cookie,以释放清漆的全部功能。

You may want to have a look in this nice summary/example on dealing with cookie requests for varnish + django 您可能想看一下这个不错的摘要/示例 ,该示例/示例处理有关varnish + django的cookie请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM