Download

Download stable version from Download page for production use, otherwise git clone the source code.

Build

  1. make TARGET=linux2628 USE_LUA=1 LUA_INC=/usr/include/lua5.3 USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1
  2. make install PREFIX=/usr/local/nuster

use USE_PTHREAD_PSHARED=1 to use pthread lib

omit USE_LUA=1 LUA_INC=/usr/include/lua5.3 USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1 if unnecessary

See HAProxy README for details.

Create config file

A minimal config file: nuster.cfg

  1. global
  2. nuster cache on data-size 100m uri /_nuster
  3. nuster nosql on data-size 200m
  4. defaults
  5. mode http
  6. frontend fe
  7. bind *:8080
  8. #bind *:4433 ssl crt example.com.pem alpn h2,http/1.1
  9. use_backend be2 if { path_beg /_kv/ }
  10. default_backend be1
  11. backend be1
  12. nuster cache on
  13. nuster rule img ttl 1d if { path_beg /img/ }
  14. nuster rule api ttl 30s if { path /api/some/api }
  15. server s1 127.0.0.1:8081
  16. server s2 127.0.0.1:8082
  17. backend be2
  18. nuster nosql on
  19. nuster rule r1 ttl 3600

nuster listens on port 8080 and accepts HTTP requests.Requests start with /_kv/ go to backend be2, you can make POST/GET/DELETE requests to /_kv/any_key to set/get/delete K/V object.Other requests go to backend be1, and will be passed to servers s1 or s2. Among those requests, /img/* will be cached for 1 day and /api/some/api will be cached for 30 seconds.

Start

/usr/local/nuster/sbin/nuster -f nuster.cfg

Docker

  1. docker pull nuster/nuster
  2. docker run -d -v /path/to/nuster.cfg:/etc/nuster/nuster.cfg:ro -p 8080:8080 nuster/nuster