View nginx + node

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

1) nginx is used to serve static files (css, js, images, etc.) 2) node serves all the "dynamic" stuff.

So for example, request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

3) nginx listens on port 80.


Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
View gist:10198753
* parse_link_header()
* Parse the Github Link HTTP header used for pageination
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
View cors-nginx.conf
# Wide-open CORS config for nginx
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
View embed.css
.gist {
color: #000;
.gist div {
padding: 0;
margin: 0;
.gist .gist-file {
View Evolution of a Python
#Newbie programmer
def factorial(x):
if x == 0:
return 1
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
View Hash.from_xml
# USAGE: Hash.from_xml(YOUR_XML_STRING)require 'rubygems'
require 'nokogiri'
# modified from
class Hash
class << self
def from_xml(xml_io)
result = Nokogiri::XML(xml_io)
View go_live.html.erb
<!-- go_live.html.erb -->
<title>Go Live!</title>
<meta name="author" content="Luid M Ruiz">
ported to ERB by @SoAwesomeMan
View ox_parsing.rb
require "awesome_print"
module XmlParsing
require "ox"
class Reader < ::Ox::Sax
def initialize file_path, target, target_handler
@target_handler = target_handler
@target = target
@file_path = file_path