Skip to content

Instantly share code, notes, and snippets.

View marklkelly's full-sized avatar

Mark Kelly marklkelly

View GitHub Profile
@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)
@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 / Dockerfile
Last active July 20, 2020 02:01
OpenResty + HTTP2 (patch) + ngx_pagespeed
FROM zokeber/centos:latest
MAINTAINER Mark Kelly <[email protected]>
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
#!/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 / 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;
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"
-- Setup Redis connection
local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect("127.0.0.1", "6379")
if not ok then
ngx.log(ngx.INFO, "REDIS: Failed to connect to redis: " .. err)
return ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end
@marklkelly
marklkelly / nginx
Last active February 15, 2019 13:54
OpenResty init script.
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
#!/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
# Install some pre-requisites
#!/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
LUANGINX_VERSION=0.9.16