Skip to content

Instantly share code, notes, and snippets.

View hamishforbes's full-sized avatar

Hamish Forbes hamishforbes

  • Christchurch, NZ
View GitHub Profile
@hamishforbes
hamishforbes / lulip.lua
Created August 29, 2013 11:02
Modified version of https://github.com/jgrahamc/lulip that plays nice with ngx_lua where `debug.getinfo(3).source` doesn't return a filepath
-- lulip: LuaJIT line level profiler
--
-- Copyright (c) 2013 John Graham-Cumming
--
-- License: http://opensource.org/licenses/MIT
local io_lines = io.lines
local io_open = io.open
local pairs = pairs
local print = print
@hamishforbes
hamishforbes / matrix-common
Created January 17, 2014 09:51
Example nginx conf for Matrix
# Push 404's to the matrix handler, this means static 404's in __data are handled by matrix too
error_page 404 = @matrix;
# Redirect server error pages to the static page /50x.html
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# Just serve data files
@hamishforbes
hamishforbes / nginx.conf
Created January 25, 2014 16:43
Minimal config to reproduce lua pending timer bug
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
lua_shared_dict test_dict 1m;
#push 404's to the matrix handler, this means static 404's in __data are handled by matrix too
error_page 404 = @matrix404;
#just serve data files
location /__data {
alias $matrix_root/data/public;
# Rewrite PHP files to matrix
location ~ asset_types/.*\.php$ {
expires off;
diff --git a/lib/ledge/ledge.lua b/lib/ledge/ledge.lua
index 4f7d1cd..4b0cdea 100644
--- a/lib/ledge/ledge.lua
+++ b/lib/ledge/ledge.lua
@@ -145,6 +145,10 @@ function _M.new(self)
enable_esi = false,
enable_collapsed_forwarding = false,
collapsed_forwarding_window = 60 * 1000, -- Window for collapsed requests (ms)
+
+ upstream = nil,
@hamishforbes
hamishforbes / ngx_crypt_errs
Created March 13, 2014 10:18
Openresty 1.5.11.1rc1 OS X errors
cc -c -pipe -O -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wno-unused-parameter -Werror -g -I/usr/local/Cellar/pcre/8.34/include -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DLUA_DEFAULT_PATH='"/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua"' -DLUA_DEFAULT_CPATH='"/usr/local/openresty/lualib/?.so"' -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/http -I src/http/modules -I src/os/unix -I ../ngx_devel_kit-0.2.19/objs -I objs/addon/ndk -I /Users/hamish/edge/ngx_openresty-1.5.11.1rc1/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -I ../ngx_lua-0.9.5/src/api -I objs \
-o objs/src/core/ngx_crypt.o \
src/core/ngx_crypt.c
src/core/ngx_crypt.c:82:5: error: 'MD5_Init' is deprecated: first deprecated in OS X 10.7 [-Werror,-Wdeprecated-declarations]
ngx_md5_init(&md5);
^
src/core/ngx_md5.h:30:25: note: expanded from macro 'ngx_md5_init'
#define ngx_md5_init MD5_Init
@hamishforbes
hamishforbes / nginx.conf
Created May 1, 2014 18:19
Single background thread
error_log logs/error.log debug;
events {
worker_connections 1024;
}
worker_processes 4;
http {
default_type application/octet-stream;
@hamishforbes
hamishforbes / nginx.conf
Last active August 23, 2024 01:01
Single backround thread in with multiple workers
error_log logs/error.log debug;
events {
worker_connections 1024;
}
worker_processes 4;
http {
default_type application/octet-stream;
{
"title": "Edge Analytics",
"services": {
"query": {
"list": {
"0": {
"query": "expires: <1407775286",
"alias": "Fresh",
"color": "#7EB26D",
"id": 0,
@hamishforbes
hamishforbes / 1.4.3.6
Created September 23, 2014 13:56
location capture X-Forwarded-For
hamish@Hamish-MBP ~/edge> curl -v -s -H'X-Forwarded-For: 123.123.123.123' -H'X-Test: foobar' localhost/test/foo
> GET /test/foo HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost
> Accept: */*
> X-Forwarded-For: 123.123.123.123
> X-Test: foobar
>
< HTTP/1.1 200 OK
< Server: ngx_openresty/1.4.3.6