6

I'm working to setup a reverse proxy cache. In nginx.conf I added the following:

location /blog {
        # Reverse Proxy
        # Cache the Blog Pages from Heroku
        proxy_cache                             STATIC;
        proxy_cache_valid               200     10m;
        proxy_cache_valid               404     1m;
        proxy_cache_use_stale   error timeout invalid_header updating http_500 http_502 http_503 http_504;

        rewrite ^/blog$             /;
        rewrite ^/blog/(.*)$    /$1;

        proxy_pass http://whispering-retreat-1.herokuapp.com;
        break;
}

However when trying to restart nginx I received the following error:

$ /opt/nginx/sbin/nginx -s stop
nginx: [emerg] "proxy_cache" zone "STATIC" is unknown in /opt/nginx/conf/nginx.conf:182

Any ideas what's the problem is with using STATIC? I just want to cache the blog pages so it doesn't hit heroku every time which is horribly slow.

Thanks

1
  • I know you only said that because its a question, but tip to everyone. NEVER EVER restart nginx without first checking if the config is valid by running "sudo nginx -t"
    – andrerpena
    Apr 16, 2019 at 19:31

2 Answers 2

6

"proxy_cache" zone "STATIC" is unknown

Means that you forgot to configure it. http://nginx.org/r/proxy_cache_path

1
  • configure what?
    – Alex Weitz
    Feb 9, 2022 at 6:20
2

As the answer above suggested, you are missing the proxy_cache_path Directive.

In your case proxy_cache_path can be:
proxy_cache_path /var/cache/nginx keys_zone=STATIC:10m;

You can find more information on Nginx Documentation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .