proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache:10m max_size=500m inactive=60m use_temp_path=off;

server {
  listen 80;

  location / {
    proxy_pass http://$FLASK_SERVER_ADDR;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location /cache-me {
    proxy_pass http://$FLASK_SERVER_ADDR;
    proxy_cache cache;
    proxy_cache_lock on;
    proxy_cache_valid 200 30s;
    proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
    proxy_cache_revalidate on;
    proxy_cache_background_update on;
    expires 20s;
  }

  location /health-check {
    add_header Content-Type text/plain;
    return 200 "success";
  }
  
}
