Welcome! Log In Create A New Profile

Advanced

Can't make nginx to cache

Mirosław Jaworski
July 21, 2009 11:03AM
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
Subject Author Posted

Can't make nginx to cache

Mirosław Jaworski July 21, 2009 11:03AM

Re: Can't make nginx to cache

Gabriel Ramuglia July 21, 2009 03:29PM

Re: Can't make nginx to cache

Mirosław Jaworski July 23, 2009 08:52AM

Re: Can't make nginx to cache

Maxim Dounin July 23, 2009 09:15AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 273
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready