Skip to content

Instantly share code, notes, and snippets.

@beldpro-ci
Created May 9, 2017 00:23
Show Gist options
  • Save beldpro-ci/ae6c06c17dd215522bbda86059e547b6 to your computer and use it in GitHub Desktop.
Save beldpro-ci/ae6c06c17dd215522bbda86059e547b6 to your computer and use it in GitHub Desktop.
Configuration for a NGINX configuration that loads some lua modules
worker_processes 1;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# by setting lua code cache to 'off' we don't
# need to reload nginx. The con for doing this is
# that the module gets reloaded on every execution
# which means that local variables from modules are
# not preserved
# (see more about the lua-nginx-module at
# https://github.com/openresty/lua-nginx-module)
lua_code_cache off;
# sets the base path that nginx will search for the
# lua files
lua_package_path '/etc/nginx/?.lua';
server {
listen 80;
server_name localhost;
location /bearer-to-basic {
# sets a lua code to execute whenever a request
# comes at this location and the rewrite phase
# of nginx is reached. Here we're just requiring
# the module with name 'bearer-to-git-basic'
rewrite_by_lua_block {
require("bearer-to-git-basic")()
}
proxy_pass http://localhost:80/auth-dump;
}
location /basic-to-bearer {
# same as in the other 'rewrite_by_lua_block'
# but this time using 'the basic-git-to-bearer'
# module
rewrite_by_lua_block {
require("basic-git-to-bearer")()
}
proxy_pass http://localhost:80/auth-dump;
}
location /auth-dump {
# Executes the 'auth-dump' module at the content
# phase. This is when we have access to the body
# of the request and all properties of it are already
# set.
content_by_la_block {
require("auth-dump")()
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment