Skip to content

Instantly share code, notes, and snippets.

View vqiu's full-sized avatar
🌴
On vacation

shuhui.qiu vqiu

🌴
On vacation
View GitHub Profile
@vqiu
vqiu / bwlimit
Created July 30, 2018 10:42 — forked from neocogent/bwlimit
Traffic shaping for Bitcoin full nodes
#!/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
@vqiu
vqiu / default.ctmpl
Created June 29, 2018 10:17 — forked from mdmsua/default.ctmpl
/etc/nginx/conf.d
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}}
@vqiu
vqiu / waf.lua
Created June 24, 2018 18:01 — forked from zahna/waf.lua
-- 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()
@vqiu
vqiu / db.sql
Created June 24, 2018 17:42 — forked from kindy/db.sql
ngx_openresty file upload
" mysql中增加一数据库,名为nginx,编码为utf8
" 增加一表,名为 uploadfile 结构为
CREATE TABLE `uploadfile` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`filehash` varchar(50) DEFAULT NULL,
`filename` varchar(100) DEFAULT NULL,
`filelen` varchar(50) DEFAULT NULL,
`contenthash` varchar(80) DEFAULT NULL,
PRIMARY KEY (`id`)

本來打算試著用 ngx_lua 取代原本用 C 實作的 access control,可是看完了「基本語法」想要找一些相關會用到的 library 都找不太到,像 lua-aws 雖然有人寫,但看起來不太完整。這樣就不能透過 lua script 存取 aws service 取得認證的資訊。

不過,想了想它網頁上 access_by_lua 的例子也沒有直接寫在裡面,就以 deleagte 的形式問了其它 uri:

location / {
    deny    192.168.1.1;
    allow   192.168.1.0/24;
    allow   10.1.1.0/16;
    deny    all;
@vqiu
vqiu / docker-compose-tick.yml
Created December 3, 2017 11:42 — forked from cdelaitre/docker-compose-tick.yml
Monitor Docker Swarm with the InfluxData TICK Stack
version: '3'
services:
# FRONT
chronograf:
# Full tag list: https://hub.docker.com/r/library/chronograf/tags/
image: chronograf
deploy:
replicas: 1
placement:
constraints:
#!/bin/bash
# Setup and enable auditd
# MUST REBOOT AFTER SETUP
#
# FUNCTIONALITIES:
#
# * Auditing user TTY
# aureport --tty
#
# * Auditing root commands (real uid)
@vqiu
vqiu / consul.lua
Created September 15, 2017 15:56 — forked from gmr/consul.lua
Dynamic Nginx upstream nodes using Consul
module("resty.consul", package.seeall)
_VERSION = '0.1.0'
function service_nodes(service)
local http = require "resty.http"
local json = require "cjson"
local hc = http:new()
local upstream = ""
@vqiu
vqiu / kerberos_setup.md
Created August 9, 2017 06:17 — forked from ashrithr/kerberos_setup.md
Set up kerberos on Redhat/CentOS 7

Installing Kerberos on Redhat 7

This installation is going to require 2 servers one acts as kerberos KDC server and the other machine is going to be client. Lets assume the FQDN's are (here cw.com is the domain name, make a note of the domain name here):

  • Kerberos KDC Server: kdc.cw.com
  • Kerberos Client: kclient.cw.com

Important: Make sure that both systems have their hostnames properly set and both systems have the hostnames and IP addresses of both systems in