Purge not working with Nginx 1.6.2
czerasz opened this issue · 3 comments
I have integrated the module with Nginx 1.6.2 in this project.
I build the project with this helper command:
./bin/build-container.sh
I start the container with Nginx inside with this helper command:
./bin/run-container.sh
Then I add the file into the cache with:
$ curl -i localhost:8080/test
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Thu, 02 Apr 2015 14:53:57 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 65
Connection: keep-alive
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Cache-Status: MISS
<h1>Current Time Is</h1>
<p>2015.02.04 14:53:57</p>
<p>/test</p>
After requesting it next time I see it's inside the cache (X-Cache-Status: HIT
):
$ curl -i localhost:8080/test
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Thu, 02 Apr 2015 14:54:54 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 65
Connection: keep-alive
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Cache-Status: HIT
<h1>Current Time Is</h1>
<p>2015.02.04 14:53:57</p>
<p>/test</p>
When I try to purge it I get a 404
:
$ curl -i -XPURGE localhost:8080/test
HTTP/1.1 404 Not Found
Server: nginx/1.6.2
Date: Thu, 02 Apr 2015 14:56:17 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
Also the second way to purge doesn't work:
$ docker exec nginx-cache-example curl -i localhost/purge/test
HTTP/1.1 404 Not Found
Server: nginx/1.6.2
Date: Thu, 02 Apr 2015 14:57:47 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
Here is the nginx.conf
which I use.
I was also able to pass the provided tests. Below is are instructions how I approached it.
Login to the container:
docker exec -it nginx-cache-example bash
Create required symlink:
ln -s /usr/bin/cpan /usr/bin/cpanm
Install required libraries - test-nginx
:
git clone https://github.com/openresty/test-nginx.git /tmp/nginx-installation/test-nginx
cd /tmp/nginx-installation/test-nginx
perl Makefile.PL
make
make install
Install required libraries - test-base-pm
:
git clone https://github.com/ingydotnet/test-base-pm.git /tmp/nginx-installation/test-base-pm
cd /tmp/nginx-installation/test-base-pm
cpan Zilla::Dist
make install
Install required libraries - Spiffy
(this takes some time):
cpan Spiffy
I then run the tests which pass without any iussues:
cd /tmp/nginx-installation/ngx_cache_purge-2.3
prove
The issue is with the $proxy_host
variable, which is empty at the time cache purge runs.
Do you have any real reason for using it instead of the $host
variable?
Hi Piotrek. Thanks for the quick feedback! I will use the $host
variable.