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

purge returns 404 #4

Closed
mostafahussein opened this issue Mar 1, 2017 · 7 comments
Closed

purge returns 404 #4

mostafahussein opened this issue Mar 1, 2017 · 7 comments
Labels
Milestone

Comments

@mostafahussein
Copy link

mostafahussein commented Mar 1, 2017

This may not an issue with the purge module itself, but i am looking for an explanation. My settings are quite simple. Just as the example but with a different cache key and I have tried the same example but still getting same result.

In vhost.conf

  location ~ /purge(/.*) {
            proxy_cache_purge  cache_proxy $scheme$request_method$host$request_uri;
  }

In nginx.conf

 proxy_cache_path /usr/local/nginx/proxy levels=1:2 keys_zone=cache_proxy:15m inactive=4h max_size=1000m use_temp_path=off;
    proxy_cache_key $scheme$request_method$host$request_uri;
    proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_403 http_404;
    proxy_cache_valid  any 1m;

When I try to purge the HTTP status is 404. I always make sure that X-Proxy-Status: HIT when requesting something like: curl -I http://example.com/test.php and trying to purge it with curl -I http://example.com/purge/test.php -XPURGE

Could example to me what is the wrong with my configuration ?
I am using nginx 10.x with this module and also tried the original one but still same result

@denji
Copy link
Member

denji commented Mar 2, 2017

  • proxy_cache_purge collision key?
    • These sections are in different vhost?
  • Are you sure that the key inside will be the same vhost (server) and the level server (http) above?
  location ~ /purge(/.*) {
    # proxy_cache_purge  cache_proxy "$scheme$request_method$host$request_uri";
    default_type text/plain; # not "application/octet-stream"
    return 200 "$scheme$request_method$host$request_uri";
  }
… {
  proxy_cache_path …
  proxy_cache_key "$scheme$request_method$host$request_uri";
  default_type text/plain; # not "application/octet-stream"
  return 200 "$scheme$request_method$host$request_uri";
}

@mostafahussein
Copy link
Author

mostafahussein commented Mar 3, 2017

I have nginx.conf with include /path/to/vhosts/*.conf where i keep a vhost - server module - for each site.
I have proxy settings under http module in nginx.conf

#nginx.conf
proxy_cache_path /usr/local/nginx/proxy/domain.com levels=1:2 keys_zone=domain.com_cache:15m inactive=4h max_size=1000m use_temp_path=off;
proxy_cache_key $scheme$request_method$host$request_uri;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504 http_403 http_404;
proxy_cache_valid  any 1m;
#domain.com.conf
    location / {
        proxy_pass http://apache_reverse;
        proxy_cache domain.com_cache;
        add_header X-Proxy-Cache $upstream_cache_status;
        # 2 rules to dedicate the no caching rule for logged in users.
        proxy_cache_bypass $nocache; # Do not cache the response.
        proxy_no_cache $nocache; # Do not serve response from cache.
    }

    location ~ /purge(/.*) {
        #proxy_cache_purge arabturkey_cache $scheme$request_method$host$request_uri;
        default_type text/plain; # not "application/octet-stream"
        return 200 "$scheme$request_method$host$request_uri";
    }
$ curl -L domain.com/purge/
httpsGETdomain.com/purge/

@denji denji added the bug label Mar 3, 2017
@davydovsky
Copy link

I have the same issue on nginx-1.10.0
nginx.conf

location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_cache tmpcache;
    proxy_cache_key    $uri$is_args$args;
    proxy_cache_valid 200 6M;
    proxy_ignore_headers Cache-Control;
    proxy_ignore_headers Set-Cookie;
    proxy_hide_header Set-Cookie;
    add_header X-Cached $upstream_cache_status;

    proxy_cache_purge  PURGE from 127.0.0.1;

    etag on;
}

I have cache file with key

...
KEY: /api/nsi/directory-items/397/
...

But when I make PURGE request on this url nginx returns 404

127.0.0.1 - - [05/May/2017:16:32:16 +0300] "PURGE /api/nsi/directory-items/397/ HTTP/1.1" 404 142 "-" "python-requests/2.13.0" "-"

@torden
Copy link
Collaborator

torden commented Sep 29, 2017

@davydovsky
I can't reproduce it. Can I see the your debug log?

@davydovsky
Copy link

@torden
I've reinstalled nginx and the ngx_cache_purge module with the latest changes from master.
Now it works as expected.

@torden
Copy link
Collaborator

torden commented Oct 18, 2017

@davydovsky
sounds good!

@mostafahussein
Could you trying to reproduce base on the changes from master?
if there are still problems, Can I see the your debug log ?

@denji
Copy link
Member

denji commented Aug 3, 2018

@denji denji closed this as completed Aug 3, 2018
@denji denji added this to the 2.5 milestone Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants