Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/json"
"errors"
"fmt"
"github.com/cactus/go-statsd-client/statsd"
"io/ioutil"
"log"
"net/http"
http {
geo $subnet {
default 0;
45.55.0.0/24 1;
}
map $subnet $value {
default "";
1 $remote_addr;
@kmjones1979
kmjones1979 / nginx.conf
Created June 2, 2016 21:12
NGINX configuration used for MaxCDN meetup demonstration in Los Angeles 2016
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
@kmjones1979
kmjones1979 / nginx.conf
Last active June 6, 2016 16:57
map argument to new variable with NGINX
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@kmjones1979
kmjones1979 / mapquest_api.py
Created June 8, 2016 05:55
Python script to parse a CSV for a ZIP code and then query Mapquest's API for details between source and destination
import requests
import csv
# zip code api variables
API_URL = 'http://www.mapquestapi.com/directions/v2/route'
KEY = 'SECRET'
DEST = 'ZIP_CODE_HERE'
# csv variables
FILE = '/path/to/geo_zip.csv'
@kmjones1979
kmjones1979 / nginx_syntax_vim.sh
Last active November 17, 2016 00:09
Enable syntax highlighting within vim for NGINX configuration files
#!/bin/bash
wget -O nginx.vim http://www.vim.org/scripts/download_script.php\?src_id\=19394
mkdir -p ~/.vim/syntax
mv nginx.vim ~/.vim/syntax/
echo "au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif" | tee -a ~/.vim/filetype.vim
@kmjones1979
kmjones1979 / backend.conf
Created November 17, 2016 04:53
Example NGINX Plus backend configuration
server {
listen 8001;
listen 8002;
server_name example.com *.example.com;
status_zone backend_800X;
location / {
return 200 "This is a server listening on $server_addr:$server_port \n";
@kmjones1979
kmjones1979 / lb.conf
Created November 17, 2016 04:55
Example NGINX Plus load balancer configuration - ODW 2016
server {
listen 80;
server_name example.com *.example.com;
status_zone example_com_80;
location / {
proxy_pass http://backend;
}
@kmjones1979
kmjones1979 / links.md
Last active March 27, 2017 04:23
ODW 2016 Webinar Links
@kmjones1979
kmjones1979 / redirect.conf
Created June 5, 2017 20:29
[NGINX Plus] Redirect all HTTP traffic to HTTPS
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
status_zone example.com_80;
location / {