Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using nginx for caching requests from the upstream apache server, however I want few blocks inside to be fetched from apache all the time. I am hoping ssi can do this, but the SSI tags are outputted to the user without being preprocessed.

 location ~* ^.+\.html$ {
        proxy_pass  http://localhost:9999;
        proxy_cache_key "$prime$scheme$host$request_uri";

        ssi on;
        ssi_silent_errors off;
        log_subrequest on;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-Country        $country_code;

        proxy_cache my-cache;


        proxy_cache_bypass $http_x_refresh_cache;
        proxy_cache_valid  200 302  30d;
        proxy_cache_valid  404      10m;
        proxy_cache_valid  any      1m;


    }

This is the relevant nginx conf.

share|improve this question
    
Turn on debugging and logging with error_log /var/log/nginx/error.log debug; and log_subrequest on; to see what does it say. –  quanta Oct 17 '11 at 10:58
    
There is nothing in the error log . –  digitalPBK Oct 17 '11 at 11:15

1 Answer 1

proxy_cache_key "$prime$scheme$host$request_uri";

This line is caching all the individual parts of the page under the same key (the URI that the user typed), so the different parts of the page are overwriting each other, and then only the last one written gets returned. You want to use $uri rather than $request_uri, so that each part of each page is cached under its own personal name.

share|improve this answer
    
Actually, on second thoughts I'm not sure that that is the cause of this particular problem -- however, if it isn't, then it is a separate problem that you will probably run into after fixing this one... –  Shish Oct 17 '11 at 17:03
    
I removed all proxy cache directives. Still ssi does not work. Does nginx enable ssi for proxy passed pages? –  digitalPBK Oct 18 '11 at 5:25
    
It does, we're using SSI to build dynamic pages and cache individual static parts at work, and the only SSI directive we're using is "ssi on;" :-/ –  Shish Oct 23 '11 at 11:13
    
Can you let me know the nginx version? and if possible share relevant parts of the conf –  digitalPBK Oct 24 '11 at 8:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.