Skip to content

Instantly share code, notes, and snippets.

View marklkelly's full-sized avatar

Mark Kelly marklkelly

View GitHub Profile
local log = ngx.log
local exit = ngx.exit
local null = ngx.null
local ERR = ngx.ERR
local INFO = ngx.INFO
local DEBUG = ngx.DEBUG
local HTTP_INTERNAL_SERVER_ERROR = ngx.HTTP_INTERNAL_SERVER_ERROR
-- Setup Redis connection
local redis = require "resty.redis"
@marklkelly
marklkelly / nginx.conf
Last active December 10, 2023 03:19
OpenResty & ssl_certificate_by_lua_file example
#Simplified for illustrative purposes.
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#!/bin/bash
set -o errexit
clear
# Set versions. Check http://openresty.org for latest version and bundled version of nginx.
OPENRESTY_VERSION=1.9.3.1
NGINX_VERSION=1.9.3
OPENSSL_VERSION=1.0.2d
NPS_VERSION=1.9.32.10
@marklkelly
marklkelly / Dockerfile
Last active July 20, 2020 02:01
OpenResty + HTTP2 (patch) + ngx_pagespeed
FROM zokeber/centos:latest
MAINTAINER Mark Kelly <marklkelly@gmail.com>
RUN touch /var/lib/rpm/*
RUN yum install -y deltarpm; yum clean all
RUN yum install -y sudo; yum clean all
# Set versions. Check http://openresty.org for latest version and bundled version of nginx.
ENV OPENRESTY_VERSION 1.9.3.1
ENV NGINX_VERSION 1.9.3
@marklkelly
marklkelly / redis_access.lua
Created November 10, 2015 17:38
PoC security proxy with OpenResty and Redis
function strsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
@marklkelly
marklkelly / age-test.sh
Created April 17, 2016 16:52
For testing max age of cached resources. bash age-test.sh <http://your-resource/> <age in milliseconds> <optional: HTTP host name>
#!/bin/bash
shopt -s extglob # Required to trim whitespace
RESOURCE=$1
AGE=$2
HOST=$3
GREEN=$(tput setaf 2)
RED=$(tput setaf 1)
WHITE=$(tput setaf 7)