Can't make nginx to cache
Mirosław Jaworski
mjaw at ikp.pl
Tue Jul 21 19:03:55 MSD 2009
Hi
Hello for the first time.
Intended config: nginx as caching reverse proxy.
nginx version: 0.7.61
Direct connect to backend:
$ telnet 192.168.10.18 80
Trying 192.168.10.18...
Connected to 192.168.10.18.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.xyz.pl
HTTP/1.1 200 OK
Date: Tue, 21 Jul 2009 13:06:01 GMT
Server: Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.2 with Suhosin-Patch
X-Powered-By: PHP/5.2.6-2ubuntu4.2
Vary: Accept-Encoding
Content-Length: 22
Content-Type: text/html
ksjdhfksjdhfksjaghfksa
Connection closed by foreign host.
Connect to fronted ( nginx ):
$ telnet A.B.C.D 80
Trying A.B.C.D...
Connected to A.B.C.D.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.xyz.pl
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 21 Jul 2009 13:06:56 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.2.6-2ubuntu4.2
Vary: Accept-Encoding
Content-Length: 22
ksjdhfksjdhfksjaghfksa
nginx config:
----------------------------------------------------------------------
worker_processes 4;
events {
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
client_body_temp_path /opt/nginx/client_temp 1 2;
proxy_temp_path /opt/nginx/proxy_temp 1 2;
fastcgi_temp_path /opt/nginx/fastcgi_temp 1 2;
proxy_cache_path /opt/nginx/cache/A.B.C.D levels=1:2
keys_zone=one:10m;
log_format main '$remote_addr - $remote_user [$time_local]
"$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
server {
listen A.B.C.D;
server_name localhost;
access_log /var/log/nginx/A.B.C.D.access.log main;
location / {
proxy_pass http://192.168.10.18:80/;
proxy_redirect off;
proxy_cache one;
proxy_pass_header Set-Cookie;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
}
}
----------------------------------------------------------------------
I don't see anything preventing caching, but cache ( path given by
proxy_cache_path ) remains empty :|
$ ls -al /opt/nginx/cache/A.B.C.D
total 4
drwxr-xr-x 2 www www 512 Jul 21 12:13 .
drwxr-xr-x 9 www www 512 Jul 21 12:13 ..
Should i do something more?
Regards
MJ
--
Mirosław "Psyborg" Jaworski
GCS/IT d- s+:+ a C++$ UBI++++$ P+++$ L- E--- W++(+++)$ N++ o+ K- w-- O-
M- V- PS+ PE++ Y+ PGP t 5? X+ R++ !tv b++(+++) DI++ D+ G e* h++ r+++ y?
"Voltaire: It is dangerous to be right when the government is wrong."
More information about the nginx
mailing list