Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to configure handle request direct from nginx using redis cache, cache already added to redis the problem is to configure nginx get the cache from redis

URL is like

Redis key is depend on param1

in the following example it use the full path as the key for redis

so i want to capture the param1 to get key which is like "cahced_page_"+param1

server {
  listen 80;
  root /home/appuser/app/current/public;
  error_log /dev/null crit; #real man don't log
  location / {
      set $redis_db "1";
      set $redis_key $uri;
      default_type   text/html;
      redis_pass redis;
      error_page 404 405 502 504 = @fallback;

  location @fallback {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      if (!-f $request_filename) {
          proxy_pass http://yourunicornupstream;

share|improve this question
Did you check ? -> Especially the part about $arg_PARAMETER ? – etagenklo Nov 27 '13 at 21:06
Yee, thanks for help on this – mohamed-ibrahim Nov 28 '13 at 14:45


location = /code.js {
  set $redis_db "1";
  set $redis_key "hashed_key_$arg_param1";
  default_type   text/javascript;
  redis_pass redis;
  error_page 404 405 502 504 = @fallback;
share|improve this answer

Your Answer


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.