Skip to content

Instantly share code, notes, and snippets.

@kentbrew
kentbrew / node-on-ec2-port-80.md
Last active February 4, 2024 19:14
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
register /home/raffi/appprofiler/commons-lang-2.5.jar;
register /home/raffi/appprofiler/scala-library.jar;
register /home/raffi/appprofiler/appprofiler_2.7.7-1.0.jar;
test_data = load 'test.tsv' as (first, second);
distances = foreach test_data {
distance = com.twitter.appprofiler.pig.piggybank.LevenshteinDistance(first, second);
generate distance, first, second;
};
package com.twitter.appprofiler.pig.piggybank
import org.apache.commons.lang.StringUtils
import org.apache.pig.{EvalFunc, FuncSpec, PigWarning}
import org.apache.pig.backend.executionengine.ExecException
import org.apache.pig.data.{DataByteArray, Tuple}
import java.io.IOException
import java.util.{List => JList}