Skip to content

Instantly share code, notes, and snippets.

View komuw's full-sized avatar

Komu Wairagu komuw

View GitHub Profile
@komuw
komuw / gist:076231fd9b10bb73e40f
Created May 20, 2015 15:59
Shell script to generate server cert, key and client certs (all self-signed)
#! /usr/bin/env bash
# Create the CA Key and Certificate for signing Client Certs
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
# Create the Server Key, CSR, and Certificate
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
@komuw
komuw / gist:5b37ad11a320202c3408
Last active August 29, 2015 14:21
generate server cert,key and client certificate and use them in Nginx.
#Taken from:
http://nategood.com/client-side-certificate-authentication-in-ngi
#reposted here to preserve history
#see: https://gist.github.com/komuW/076231fd9b10bb73e40f for a bash script to auto-generate all this
Client Side Certificate Auth in Nginx
Why Client-Side Certificate Authentication? Why nginx?
I sometimes peruse the ReST questions of stackoverflow.com. Many times I see questions about authentication. There are many options (Basic HTTP Auth, Digest HTTP Auth, OAuth, OAuth Wrap, etc.) however when security is of importance, I like to recommend client side certificates. This is the route our team at ShowClix chose when implementing our API.
@komuw
komuw / django 1.3wsgi.py
Created March 17, 2015 11:27
django 1.3 wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
@komuw
komuw / gist:00fca08aa2c81c05d97e
Last active September 26, 2016 10:07
ssl on nginx django
#A very good resource on configuring some webservers with ssl:
https://wiki.mozilla.org/Security/Server_Side_TLS
# create a file: /etc/nginx/sites-enabled/app_name.conf and also link to /etc/nginx/sites-available/app_name.conf
# and edit as:
log_format timed_combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time';
@komuw
komuw / gist:fb746bbb85ddcc3d00ac
Created January 29, 2015 09:07
ansible execute bash script
name: execute bash script
command: bash {{ APP_DIR }}/some_script.sh
@komuw
komuw / gist:b98d1b0bdeb6940cc41a
Created January 16, 2015 11:23
monit-odoo/openerp conf file
set daemon 600 #in seconds
set logfile /home/webapp/log/monit.log
check process rabbit with pidfile /var/run/odoo.pid
start program = "/etc/init.d/odoo start"
stop program = "/etc/init.d/odoo stop"
@komuw
komuw / gist:caeb33a164d0d6d6310a
Created January 5, 2015 09:04
output log for vagrant up
INFO global: Vagrant version: 1.7.1
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.1/bin/vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/bin/../embedded"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_DETECTED_OS="Linux"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"
@komuw
komuw / install ubuntu crouton
Last active August 29, 2015 14:11
install ubuntu via crouton in a chromebook
1. open a browser and go to https://goo.gl/fd3zc, that will download crouton
2. hit Ctrl+alt+T and then type shell and press enter
$ shell
3. install ubuntu via
$ sudo sh ~/Downloads/crouton -r trusty -t xfce
#that will install ubuntu 14.04 with xfce desktop environment
4. to list available versions:
@komuw
komuw / install NVM and nodeJS.yml
Created November 20, 2014 17:40
Ansible task to install nvm and nodeJS
#first seen here: http://www.snip2code.com/Snippet/63701/Ansible-task-to-install-nvm-and-node
# Here is how to install nvm and node in an Ansible task.
# I tried a bunch of different things, and as usual it's simple, but you have to get it right.
# The important part is that you have to shell with /bin/bash -c and source nvm.sh
---
- name: Install nvm
shell: >
curl https://raw.githubusercontent.com/creationix/nvm/v0.7.0/install.sh | sh
creates=/home/{{ ansible_user_id }}/.nvm/nvm.sh
@komuw
komuw / terminal_VPN_client
Last active November 26, 2022 21:53
commandline VPN client
If for any reason you don't have a GUI VPN client(you like running headless ubuntu
or have ubuntu installed on a chromebook). You can use vpnc as a command line VPN client
#this is a comment
#install vpnc
$ sudo apt-get install network-manager-vpnc
#look to see if you have vpnc installed
$ sudo vpnc --help #use sudo to run vpnc command
#if not installed, install it:
$ sudo apt-get install vpnc