Skip to content

Instantly share code, notes, and snippets.

@naokij
naokij / static_cdn.vcl
Created January 14, 2020 09:05
static_cdn.vcl
vcl 4.0;
import http;
import directors;
# We define the origin servers
# assumption they listen on port 80, please change it if not true
backend origin_a {
.host = "103.234.96.112";
.port = "80";
}
@naokij
naokij / Caddyfile
Last active May 26, 2017 14:20
MinDoc 部署文件
#请替换成你的网址
https://doc.example.com {
#将下面的路径替换成你的MinDoc路径
root /go/src/github.com/lifei6671/godoc/
proxy / localhost:8181 {
header_upstream Host {host}
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream X-Forwarded-Proto {scheme}
except /static /uploads /cache
@naokij
naokij / validate_ldap.go
Last active May 15, 2017 09:30
ldap验证
package controllers
import (
"errors"
"fmt"
"bitbucket.org/emagine/vdrill-cp/config"
"gopkg.in/ldap.v2"
)
@naokij
naokij / caddy.service
Created September 19, 2016 02:39
caddy systemd unit file
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
[Service]
Restart=on-failure
@naokij
naokij / gist:0550005be8d469b9bf78
Created May 29, 2014 08:54
go语言map中的坑
package main
type HostReport struct {
Download string
Upload string
Traceroute string
}
func main(){
reports := make(map[string]HostReport)
}
@naokij
naokij / nginx
Created October 11, 2013 04:33
nginx start script with chkconfig support
#!/bin/bash
# chkconfig: 2345 88 88
# description: starts the nginx web server
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
@naokij
naokij / gist:4011810
Created November 4, 2012 12:57
nginx 反向代理设置
server
{
listen 80;
server_name yoursite.com;
location / {
proxy_pass http://sourcesite.com/;
proxy_redirect default;
proxy_set_header X-Real-IP $remote_addr;
@naokij
naokij / spider-killer.sh
Created October 24, 2012 03:24
根据nginx日志文件过滤spider
#! /bin/bash
LOGFILE=/var/log/nginx/access.log
PREFIX=/etc/spiders
#日志中大部分蜘蛛都有spider的关键字,但是百度的不能封,所以过滤掉百度
grep 'spider' $LOGFILE |grep -v 'Baidu' |awk '{print $1}' >$PREFIX/ip1.txt
# 封掉网易的有道
grep 'YoudaoBot' $LOGFILE | awk '{print $1}' >>$PREFIX/ip1.txt
#封掉雅虎
grep 'Yahoo!' $LOGFILE | awk '{print $1}' >>$PREFIX/ip1.txt
# 过滤掉信任IP
@naokij
naokij / graylog2-blacklist-2-rsyslog.rb
Created February 20, 2012 09:21
ruby script to create rsyslog discarding terms based on graylog2 blacklist terms
require 'rubygems'
require 'mongo'
@conn = Mongo::Connection.new
@db = @conn['graylog2']
@db.authenticate('grayloguser','grayloguser-mongo-passwd')
@coll = @db['blacklists']
@conf_file = '/etc/rsyslog_disgarding.conf'
@conf_content = ""
@file = File.open(@conf_file,'r')
@naokij
naokij / graylog2-web-interface
Created February 20, 2012 04:15
/etc/init.d/graylog2-web-interface
#!/bin/bash
#
# graylog2-web-interface: graylog2 web interface
#
# chkconfig: - 98 02
# description: Starts graylog2-web-interface using passenger-standalone. \
# Uses RVM to use switch to a specific ruby version.
#
# config