Skip to content

NGinx proxy cache

Ukazka fungujici konfigurace

http {
    # konfigurace cache  Uloziste                                  NAZEV          
    proxy_cache_path     /tmp/nginx/cache  levels=1:2    keys_zone=DOWNLOADS_CACHE:10m
    inactive=24h  max_size=1g;


    # Definice serveru
    server {
        listen 80;
        server_name caching.reverse.proxy;

        location /downloads/ {
            # Protokol nesmi byt https
            proxy_pass             http://10.10.1.27;
            #proxy_set_header       Host $host;

            # Musi byt on
            proxy_buffering        on;

            # Nazev cache, ktera se pouziva
            proxy_cache            DOWNLOADS_CACHE;

            # Navratove kody, ktere se budou cachovat 
            proxy_cache_valid      200 300 301 302 303  1h;

            # Definice navratovych kodu
            proxy_cache_use_stale  error timeout invalid_header updating
                                   http_500 http_502 http_503 http_504;
        }
    }
}