【问题标题】:How to configure an Nginx > Varnish > uWSGI setup如何配置 Nginx > Varnish > uWSGI 设置
【发布时间】:2013-09-18 11:22:40
【问题描述】:

我发现了这个例子http://projects.unbit.it/uwsgi/wiki/Example(参见:Varnish and nginx, the best way (0.9.8.4)),它建议将 Varnish 放在 Nginx 和 uWsgi 之间。

我正在尝试让这个在我的 Django 网站上工作。

一切都在运行,但是当我使用 varnishlog 时,我在访问我的网站时看不到任何显示。看来varnish的作用不大。

我的配置是:

Nginx:(将真实域名替换为“域”)

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:(皇帝进程使用的.ini conf文件的相关部分)

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

清漆:

/etc/default/清漆

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

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


sub vcl_recv {    
    set req.backend = uwsgi;
}

【问题讨论】:

  • 看看this post中间的“重启守护进程”部分可能会给你一些答案

标签: django nginx varnish uwsgi


【解决方案1】:

Varnish 只为未设置任何 cookie 的请求提供缓存响应。您需要确保取消设置不必要的 cookie 以释放 varnish 的全部功能。

你可能想看看这个nice summary/example on dealing with cookie requests for varnish + django

【讨论】:

    猜你喜欢
    • 2011-06-26
    • 1970-01-01
    • 2020-01-23
    • 2016-04-30
    • 2014-05-29
    • 2012-08-04
    • 2012-03-31
    • 2016-10-17
    • 2020-03-04
    相关资源
    最近更新 更多