Welcome! Log In Create A New Profile

Advanced

Caching Reverse proxy, Matching Header Field

Posted by liaan 
Caching Reverse proxy, Matching Header Field
June 21, 2011 03:20AM
Hi All

I'm completely lost on this one and hoping someone can help.

I have backend Nginx server with separate front end caching server.

The caching server must only cache pages with a header containing either "max-age" or custom header rcgstatic = cache

I'm currently just adding test header to see if config works ("koo2")

Here my current config, but the If statement never matches, although if i use %upstream_http_rcgstatic in logs, it logs correctley

server {
listen 80 ;
server_name www.example.com;

access_log /var/log/nginx/www.example.com_access.log cache;
error_log /var/log/nginx/www.example.com_error.log debug;

location / {

proxy_pass http://vps133.example.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host www.example.com;
resolver 127.0.0.1;
proxy_cache_valid 200 1m;
proxy_cache magento;
proxy_cache_key $scheme$proxy_host$uri$is_args$args;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
add_header koos "aaa";
#proxy_ignore_headers "Cache-Control";
#proxy_ignore_headers "Expires";
#proxy_ignore_headers Set-Cookie;

if ($upstream_http_rcgstatic ~* cache) {
add_header koo2 "bbb";
}
if ($http_rcgstatic = 'cache') {
add_header koo2 "aaa";
}


Sample Header:

HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx/1.0.4
Date: Tue, 21 Jun 2011 07:18:10 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
X-Powered-By: PHP/5.3.6
Set-Cookie: frontend=gvjv8l4n5ohab81p7jpjafbsv1; expires=Tue, 21-Jun-2011 08:18:10 GMT; path=/; domain=www.example.com; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Magento-Lifetime: 86400
X-Magento-Action: cms_index_index
Cache-Control: max-age=86400
Rcgstatic: cache
koos: aaa
Length: unspecified [text/html]



nginx: nginx version: nginx/1.0.4
nginx: built by gcc 4.1.2 20080704 (Red Hat 4.1.2-50)
nginx: configure arguments: --with-http_geoip_module



Edited 1 time(s). Last edit at 06/21/2011 03:20AM by liaan.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 122
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