django - 如何配置Nginx> Varnish> uWSGI设置

标签 django nginx varnish uwsgi

我发现了这个示例http://projects.unbit.it/uwsgi/wiki/Example(请参阅:Varnish和nginx,最好的方法(0.9.8.4)),建议将Varnish放在Nginx和uWsgi之间。

我正在尝试让它在我的Django网站上正常工作。

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

我的配置是:

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 :(皇帝进程使用的.ini conf文件的相关部分)
socket = 127.0.0.1:3031
protocol = http
module = website.wsgi:application

漆:

/etc/默认/Varnish
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;
}

最佳答案

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

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

关于django - 如何配置Nginx> Varnish> uWSGI设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18870916/

相关文章:

python - Django makemessages 不创建新添加的语言

django - UNIQUE constraint failed : auth_user. username with registering with email

python - Celery 从 Django 模块内部记录到文件

python - 如何在 Django 中将 S3 文件附加到电子邮件

docker - Docker + Nginx允许来自外部docker的上游gunicorn

python - 在指定位置提供 django 应用程序 (NGINX)

python - 带有 Flask 应用程序的 uwsgi 给出 "callable not found or import error"

unit-testing - Mockito - 无法在 HttpEntity 上初始化 Spy

Symfony2和Varnish-了解其工作原理

wordpress - Varnish 返回错误,重定向过多