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
-- https://github.com/openresty/lua-nginx-module#nginx-api-for-lua | |
-- https://www.nginx.com/resources/wiki/modules/lua/ | |
-- http://www.staticshin.com/programming/definitely-an-open-resty-guide/ | |
-- access_by_lua_file /path/to/waf.lua; | |
-- examine request | |
ngx.req.read_body() | |
local request_method = ngx.req.get_method() | |
local get_args = ngx.req.get_uri_args() | |
local post_args, err = ngx.req.get_post_args() |
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
server { | |
listen 80; | |
{{range services}} | |
{{if and (ne .Name "consul") (ne .Name "nginx")}} | |
{{range service .Name}} | |
location /{{.Name}}/v{{.ID}} { | |
rewrite /{{.Name}}/v(\d+)\.\d+\.\d+(.*) /{{.Name}}/v$1$2 break; | |
proxy_pass http://{{.Address}}:{{.Port}}; | |
} | |
{{end}} |
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
#!/bin/bash | |
# Copyright (c) 2013 The Bitcoin Core developers | |
# Distributed under the MIT software license, see the accompanying | |
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
#network interface on which to limit traffic | |
IF="wlan0" | |
#limit of the network interface in question | |
LINKCEIL="5mbit" | |
#limit outbound Bitcoin protocol traffic to this rate |
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
-- apt-get install nginx-extras # to get nginx with lua support | |
-- apt-get install luarocks | |
-- apt-get install lua-nginx-redis | |
-- luarocks install lua-requests | |
-- In your nginx config file add two lua dict outside server definition | |
-- | |
-- lua_shared_dict ip_whitelist 1m; | |
-- lua_shared_dict ip_asklist 1m; | |
-- server { | |
-- |
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
function FindProxyForURL(url, host) { | |
var proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT"; | |
var black = "PROXY 127.0.0.1:65535"; | |
var direct = "DIRECT"; | |
var PROXY_LIST = [ | |
"instagram.com", | |
"google.com", | |
"facebook.com", |
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
options { | |
directory "/tmp"; | |
listen-on-v6 { none; }; | |
forwarders { | |
127.0.0.1 port 2053; | |
}; | |
auth-nxdomain no; # conform to RFC1035 |
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_c = require "resty.redis" | |
local ok, new_tab = pcall(require, "table.new") | |
if not ok or type(new_tab) ~= "function" then | |
new_tab = function (narr, nrec) return {} end | |
end | |
local _M = new_tab(0, 155) |
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
worker_processes 1; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
lua_shared_dict token_bucket 10M; | |
lua_shared_dict stats 5M; | |
init_by_lua ' |
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
worker_processes 2; | |
error_log /var/log/nginx/error.log info; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
init_by_lua ' | |
function split(inputstr, sep) |
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
{{ $cfg := .Cfg }} | |
{{ $IsIPV6Enabled := .IsIPV6Enabled }} | |
{{ $healthzURI := .HealthzURI }} | |
{{ $backends := .Backends }} | |
{{ $proxyHeaders := .ProxySetHeaders }} | |
daemon off; | |
worker_processes {{ $cfg.WorkerProcesses }}; | |
pid /run/nginx.pid; | |
{{ if ne .MaxOpenFiles 0 }} |