This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build dependencies for OpenResty. | |
sudo apt-get install build-essential libpcre3-dev libssl-dev libgeoip-dev | |
# Install standard Nginx first so that you get the relevant service scripts installed too | |
sudo apt-get install nginx | |
# If you want to access Postgres via Nginx | |
sudo apt-get install libpq-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zlib = require('zlib'); | |
var redis = require('redis'); | |
var redisClient = redis.createClient(); | |
var crypto = require('crypto'); | |
// Our custom caching write function | |
function cached(body, lifetime, type) { | |
var key = this.req.originalUrl; | |
var res = this; | |
var etag, len; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local redis = require "resty.redis" | |
local red = redis:new() | |
red:set_timeout(1000) -- 1 sec | |
local ok, err = red:connect("127.0.0.1", 6379) | |
if not ok then | |
ngx.log(ngx.ERR, "Redis failed to connect") | |
return ngx.exit(ngx.HTTP_SERVICE_UNAVAILABLE) | |
end |
NewerOlder