Skip to content

Instantly share code, notes, and snippets.

Avatar
I may be slow to respond.

hzbd

I may be slow to respond.
  • 049-0241
View GitHub Profile
@hzbd
hzbd / nginx_logging_http_and_stream.conf
Last active Sep 12, 2020
Nginx logging json format(http(s)&stream)
View nginx_logging_http_and_stream.conf
log_format json_http_combined escape=json
'{ "@timestamp":"$time_iso8601",'
'"server_name":"$server_name",'
'"status":$status,'
'"bytes_sent":$bytes_sent,'
'"body_bytes_sent":$body_bytes_sent,'
'"remote_addr":"$remote_addr",'
'"request_time":$request_time,'
'"request_id":"$request_id",'
@hzbd
hzbd / db-setup.sql
Created Aug 16, 2020 — forked from gka/db-setup.sql
load geoip database into mysql
View db-setup.sql
DROP TABLE IF EXISTS location;
CREATE TABLE IF NOT EXISTS `location` (
`locId` int(11) unsigned NOT NULL AUTO_INCREMENT,
`country` varchar(2) DEFAULT NULL,
`region` varchar(2) DEFAULT NULL,
`city` varchar(1000) DEFAULT NULL,
`postalCode` varchar(10) DEFAULT NULL,
`latitude` float DEFAULT NULL,
`longitude` float DEFAULT NULL,
@hzbd
hzbd / subnet.py
Created Nov 3, 2019 — forked from vndmtrx/subnet.py
Python 3 simple subnet calculator
View subnet.py
#!/usr/bin/env python3
# Use: ./subnet.py <ip/cidr>
# Alt: ./subnet.py <ip> <mask>
import sys
if __name__=="__main__":
addr = [0, 0, 0, 0]
mask = [0, 0, 0, 0]
cidr = 0
@hzbd
hzbd / subnet.py
Created Nov 3, 2019 — forked from vndmtrx/subnet.py
Python 3 simple subnet calculator
View subnet.py
#!/usr/bin/env python3
# Use: ./subnet.py <ip/cidr>
# Alt: ./subnet.py <ip> <mask>
import sys
if __name__=="__main__":
addr = [0, 0, 0, 0]
mask = [0, 0, 0, 0]
cidr = 0
@hzbd
hzbd / nginx.conf
Created Aug 27, 2019 — forked from jrom/nginx.conf
nginx hack for multiple conditions
View nginx.conf
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
View Bootstrap Checkbox Select All Or Cancel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap Table Checkbox Select All and Cancel</title>
<link href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h2>Bootstrap Table Checkbox Select All and Cancel</h2>
<table class="table table-striped">
View ip_blacklist.lua
-- a quick LUA access script for nginx to check IP addresses against an
-- `ip_blacklist` set in Redis, and if a match is found send a HTTP 403.
--
-- allows for a common blacklist to be shared between a bunch of nginx
-- web servers using a remote redis instance. lookups are cached for a
-- configurable period of time.
--
-- block an ip:
-- redis-cli SADD ip_blacklist 10.1.1.1
-- remove an ip:
@hzbd
hzbd / cors.nginxconf
Created Feb 6, 2018 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
View cors.nginxconf
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
@hzbd
hzbd / nginx-nodejs-cors
Created Dec 5, 2017 — forked from m4ttbrock/nginx-nodejs-cors
Nginx Nodejs CORS to subdomain
View nginx-nodejs-cors
server {
listen 80;
server_name subdomain.example.com;
access_log /var/log/nginx/example.access.log;
location / {
if ($http_origin ~* (https?://.*\.example\.com(:[0-9]+)?)) {
set $cors "true";
@hzbd
hzbd / nginx.conf
Created Nov 28, 2017 — forked from kmjones1979/nginx.conf
This is an example NGINX configuration for the blog: Performing A/B Testing with NGINX - This example demonstrates the sticky route functionality
View nginx.conf
events { worker_connections 2014; }
http {
default_type text/plain;
log_format cookie '$cookie_route - $route_cookie, '
'$request_uri - $route_uri, '
'$route - $upstream_addr';
error_log /var/log/nginx/debug_error.log debug;
You can’t perform that action at this time.