Skip to content

Instantly share code, notes, and snippets.

@ffjia
ffjia / nginx.conf
Last active August 29, 2015 14:17 — forked from somebox/nginx.conf
# The following recipe works with upstream rails proxy for custom 404s and 500s.
# Errors are usually handled via rails except if proxy is really down, in which case
# nginx needs a bit more configration.
server {
# ...
location / {
error_page 404 = @rails; # let rails show a page with suggestions
try_files maintenance.html @rails;
#dynamic port forwarding, binds a socket on the local machine
ssh -D 8080 user@host
#tunnel through proxy examples
chromium-browser --proxy-server="socks5://localhost:8080"
curl --socks5 localhost:8080 url
#most apps should recognize this
export HTTP_PROXY="socks5://localhost:8080"

Serving multiple webapps from different folders

November 29, 2011 developmentNginx

Few days ago I had to add a wordpress installation within the same environment where a Codeigniter app was already running happily and undisturbed.

It took me a while to figure out how to keep separate folders on the filesystem, and serve the blog from a subfolder of the main domain:

# Usage:
#
# Start with:
#
# sudo /use/local/sbin/nginx -c /path/to/this/nginx.conf
#
# Tail logs:
#
# $ sudo tail -f /tmp/access.log /tmp/error.log /tmp/match.log
#

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
# Based on https://gist.github.com/fernandoaleman/5083680
# Start the old vagrant
$ vagrant init ubuntu_saucy
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
/var/log/supervisor/*.log {
weekly
rotate 52
compress
delaycompress
notifempty
missingok
copytruncate
}
@ffjia
ffjia / .vimrc
Created September 30, 2013 07:00
" Functions
" ================
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Make script executable
function SetScriptExecutable()
" TODO make shell script executable first
if synIDattr(synID(1,1,1),"name")=="perlSharpBang"
execute ':!(if [ \! -x '.expand("<afile>").' ]; then chmod u+x '.expand("<afile>").'; fi)'
"elseif exists("b:is_sh") || exists("b:is_kornshell") || exists("b:is_bash")
#!/bin/bash
# Assumptions:
#
# Puppet >= 2.7 is installed on this machine
# puppet-lint is installed on this machine
# ERB is installed on this machine
# Adjust LINTFLAGS as appropriate
# Redirect output to stderr.
#!/bin/sh
# Author: RA <[email protected]>
USAGE(){
echo "Usage:fetchsub [eng] file"
}
[ $# -eq 0 -o "$1" = '--help' ] && USAGE && exit 0
ERROR(){