Using nginx to serve content directly out of a redis cache

前端 未结 3 486
别跟我提以往
别跟我提以往 2020-12-30 04:36

I am using nginx to pass requests to a Node app. The app basically acts as a remote cache for html (checks to see if what the user is requesting is in the redis db, if it is

3条回答
  •  抹茶落季
    2020-12-30 05:05

    Maybe something more difficult to setup than Webdis but you can do that directly in the nginx daemon with some extra modules like redis2-nginx-module. You will have to recompile nginx.

    There is some good examples of configuration on the home page.

    For instance :

    # GET /get?key=some_key
    location /get {
        set_unescape_uri $key $arg_key;  # this requires ngx_set_misc
        redis2_query get $key;
        redis2_pass foo.com:6379;
    }
    

    Of course, with a little more nginx configuration, you can get another URL pattern.

    Note that for this example, you will have to compile ngx_set_misc module too.

提交回复
热议问题