FRiCKLE / ngx_cache_purge

nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.
http://labs.frickle.com/nginx_ngx_cache_purge/
Other
1.06k stars 311 forks source link

/purge/ 404 using wget/CURL/wp_remote_get() - 200 from browser/postman #58

Open mtx-z opened 7 years ago

mtx-z commented 7 years ago

Hello !

I have an issue using the module. The purge URL are working great (200when file cache exist and deleted, 404when file cache not exist).

Getting those URL from my browser or Postman purge correctly the cache.

Now, getting the SAME URL from wget/CURL/wp_remote_get() fail and always throw 404. This is the exact same URL, tested from same server and other server (wget/curl).

As seen here i tried to force a user-agent, but still the same. I only have 200 and cache purged when URL is acceded from my browser or postman.

I'm Using HTTP2/HTTPS latest Nginx. I tried use HTTP2 with wp_remote_get() without success (header http_versionstill 1.1) and with curl --http2 (Goes 404).

All wget/CURL/wp_remote_get() always goes to 404. Nginx access.log have the GET tracking saved: (for all test, refreshed cache, checked that file was here and delete was ok from browser GET cache purge URL - 0.0.0.1 is My IP replaced, 0.0.0.2 is Server IP replaced)

Me trying to purge from my browser: OK (200 purge OK) 0.0.0.1 - - [04/Aug/2017:14:42:04 +0200] "GET /purge/alphonse/helene-l/ HTTP/2.0" 200 364 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"

Me trying to purge from wp_remote_get() not changing user-agent: NOK (404) 0.0.0.2 - - [04/Aug/2017:14:42:13 +0200] "GET /purge/alphonse/helene-l/ HTTP/1.1" 404 162 "https://domain.com/purge/alphonse/helene-l/" "WordPress/4.8; https://mtx.io"

Me trying to purge from CURL HTTP2 not changing user-agent: NOK (404) 0.0.0.2 - - [04/Aug/2017:15:22:58 +0200] "GET /purge/alphonse/helene-l/ HTTP/2.0" 404 162 "-" "curl/7.52.1"

Me trying to purge from wp_remote_get() changing user-agent: NOK (404) 0.0.0.2 - - [04/Aug/2017:15:19:15 +0200] "GET /purge/alphonse/helene-l/ HTTP/1.1" 404 191 "https://domain.com/purge/alphonse/helene-l/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"

Meaning that the plugin Wordpress Nginx Helper dont work as use wp_remote_get()...

Anything i'm missing to get the request Work ?

Thanks a looot !

TrurlMcByte commented 6 years ago

check used "Accept-Encoding" in request also

mtx-z commented 6 years ago

Is there any specific value I should set ? Thanks.

wmalagutti commented 6 years ago

Hello. I'm using Nginx Helper Wordpress Plugin (https://wordpress.org/plugins/nginx-helper/) and i'm facing the same problem. Fixed editing the following line on the plugin:

wp-content/plugins/nginx-helper/purger.php In line 306 change from $response = wp_remote_get( $url );

to

$response = wp_remote_get( $url,array('headers'=>array('Accept-Encoding' => 'gzip, deflate')) );

With cURL do: curl -I http://url.com/purge/ -H 'Accept-Encoding: gzip, deflate'