Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: stats for cached responses with error_page directive do not create a cache file #23

Merged
merged 1 commit into from
Oct 15, 2015

Conversation

wandenberg
Copy link
Contributor

When a request fail and have an error_page configured for it the vts module will not have access to r->cache because a cache file isn't created.
The problem can be easily reproduced with any request to a nginx with the bellow configuration.

pid         logs/nginx.pid;
error_log   logs/nginx-main_error.log debug;

worker_processes    2;

events {
  worker_connections  1024;
  use                 epoll; # Linux
}

http {
  default_type    text/plain;

  vhost_traffic_status_zone;

  types {
      text/html   html;
  }

  log_format main  '[$time_local] $host "$request" $request_time s '
                   '$status $body_bytes_sent "$http_referer" "$http_user_agent" '
                   'cache_status: "$upstream_cache_status" args: "$args '
                   'sorted_args: "$sorted_querystring_args" ';

  access_log       logs/nginx-http_access.log;

  proxy_cache_path /tmp/cache levels=1:2 keys_zone=zone:10m inactive=10d max_size=100m;

  error_page   404     /error_pages;
  error_page   502 503 504  /error_pages;

  server {
    listen          8080;

    access_log       logs/nginx-http_access.log main;

    location /status {
      vhost_traffic_status_display;
      vhost_traffic_status_display_format json;
    }

    location /error_pages {
      return 200 "Some ERROR happened\n";
    }

    location / {
      proxy_pass http://localhost:8081;

      proxy_cache zone;
      proxy_cache_key "$request_uri";
      proxy_cache_valid 200 10m;
      proxy_cache_valid any 2m;
    }
  }
}

vozlt added a commit that referenced this pull request Oct 15, 2015
Bugfix: stats for cached responses with error_page directive do not create a cache file
@vozlt vozlt merged commit aca8fab into vozlt:master Oct 15, 2015
@vozlt
Copy link
Owner

vozlt commented Oct 15, 2015

Thanks for the patch.

@vozlt vozlt mentioned this pull request Oct 15, 2015
@vozlt vozlt added the bug label Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants