Skip to content

Instantly share code, notes, and snippets.

James Jackson jamesbjackson

Block or report user

Report or block jamesbjackson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nginx_openresty_deb.sh
#!/bin/bash -x
#---------------------------------------------------------------------------------------------------
# Variables
#---------------------------------------------------------------------------------------------------
#Set the software versions to be downloaded and installed.
openresty_version="1.11.2.2"
#----------------------------------------------------------------------------------------------------------------------------
View rancher_single_server_install.md

Rancher Single Server Install

Install Docker

sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
apt-cache policy docker-ce
View Fix redis server startup warnings, redis tuning performance on Ubuntu 16.04.md
  • Maximum Open Files
You requested maxclients of 10000 requiring at least 10032 max file descriptors.
Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
@jamesbjackson
jamesbjackson / rate-limit.lua
Created Jul 31, 2019 — forked from jbaiter/rate-limit.lua
Simple Nginx Rate Limiting with Lua, redis and redis-cell
View rate-limit.lua
-- Requires the `redis-cell` module to be installed in Redis: https://github.com/brandur/redis-cell
local redis = require "nginx.redis"
local red = redis:new()
red:set_timeout(1000)
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.log(ngx.ERR, "failed to connect to redis: ", err)
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
@jamesbjackson
jamesbjackson / gist:6ef38d59761517dbf474b55fdcdf4f13
Created Jul 4, 2019 — forked from dantswain/gist:fdfb1c2c86e4d940a8f5
Convert Elixir config.exs to Erlang sys.config
View gist:6ef38d59761517dbf474b55fdcdf4f13
#!/usr/bin/env elixir
# Convert an Elixir config.exs to an erlang sys.config
#
# Usage: elixir_to_sys_config config.exs > sys.config
# First argument is the Elixir config.exs file
# Writes to stdout
# You probably want to set MIX_ENV accordingly
#
# 2015 by Dan Swain, dan.t.swain@gmail.com
@jamesbjackson
jamesbjackson / update_cache.rake
Created Jul 3, 2019 — forked from apsoto/update_cache.rake
Sync Chef Cookbooks and Roles with Server
View update_cache.rake
#
# Tasks to keep your repository in sync with your Chef Server
#
# Author:: Matthew Kent (<mkent@magoazul.com>)
# Copyright:: Copyright (c) 2010 Matthew Kent
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@jamesbjackson
jamesbjackson / README.md
Created May 21, 2019
How to show current HTTP requests on any server
View README.md

How to show current HTTP requests on any server

via https://dev.to/codeenigma/how-to-show-current-http-requests-on-any-server-mmp

"If you’re ever need to see incoming HTTP requests, maybe to check incoming headers, you want to know what cookies are being set, or get some clues as to why things aren’t being cached, the following command might be helpful:"

sudo tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "........(GET |HTTP\/|POST |HEAD )|[A-Za-z0-9-]+: " | sed -r 's/........(GET |HTTP\/|POST |HEAD )/\n\1/g'

"It’s a bit of a mouthful, but it shows incoming HTTP requests direct from the network interface, and formats them in a readable way for humans. The nice thing is that you can then use grep with the output to show things like incoming cookies, or request headers. Probably more useful for monitoring requests than watching log files and guessing."

@jamesbjackson
jamesbjackson / Makefile
Created May 17, 2019 — forked from paulfurley/Makefile
Makefile for activating a virtualenv and installing requirements. Uses requirements-to-freeze.txt / requirements.txt pattern
View Makefile
# Put *unversioned* requirements in `requirements-to-freeze.txt` as described below.
# `requirements.txt` will be automatically generated from `pip freeze`
# https://www.kennethreitz.org/essays/a-better-pip-workflow
venv/bin/activate: requirements-to-freeze.txt
rm -rf venv/
test -f venv/bin/activate || virtualenv -p $(shell which python3) venv
. venv/bin/activate ;\
pip install -Ur requirements-to-freeze.txt ;\
pip freeze | sort > requirements.txt
@jamesbjackson
jamesbjackson / attributes.rb
Created Apr 23, 2019 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
View attributes.rb
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@jamesbjackson
jamesbjackson / Dockerfile
Created Apr 10, 2019 — forked from majodev/Dockerfile
netdata daemonset on kubernetes
View Dockerfile
FROM netdata/netdata:latest
MAINTAINER YOUR_EMAIL
# add netdata user to root group (access volumne mounts from host)
RUN apk --no-cache add shadow
RUN usermod -a -G root netdata
ENTRYPOINT ["/usr/sbin/run.sh"]
You can’t perform that action at this time.