How to enable nginx proxy caching for mezzanines

Our stack is nginx - gunicorn is a mezzanine (django cms) running on an EC2 instance. Everything works, but I can't enable nginx proxy_cache. Here is my minimal config:

upstream %(proj_name)s {
    server 127.0.0.1:%(gunicorn_port)s;
}

proxy_cache_path /cache keys_zone=bravo:10m;

server {
    listen 80;
    listen 443;
    server_name %(live_host)s;
    client_max_body_size 100M;
    keepalive_timeout 15;

    location /static/ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
        root %(proj_path)s;
    }

    location / {
        expires 1M;
        add_header X-Proxy-Cache $upstream_cache_status;
        proxy_cache bravo;
        proxy_ignore_headers Cache-Control Expires Set-Cookie;

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_pass http://%(proj_name)s;
    }
}

      

Sample response:

HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Wed, 07 Jan 2015 03:43:47 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Vary: Cookie, Accept-Language
Content-Language: en
Expires: Fri, 06 Feb 2015 03:43:47 GMT
Cache-Control: max-age=2592000
X-Proxy-Cache: MISS
Content-Encoding: gzip

      

I have a Mezzanine middleware middleware and it returns responses with Set-Cookie headers, but proxy_ignore_headers should ignore this.

I did chmod 777 in the proxy_cache_path dir (/ cache), so it shouldn't be a permissions issue.

Error logging was enabled but generated nothing.

proxy_cache_path

continues to remain completely empty ...

Why isn't nginx caching anything with this configuration?

+3


source to share





All Articles