NodeJS HTTPS guard with AWS ELB

Running NodeJS behind ELB and proxying https? What happens if someone didn’t configure TLS? Now your app is processing sensitive data over the clear web. What a bad idea! Catch it in code instead.

First when your app is being set up, trust the first proxy.

app.set('trust proxy', 1) // trust first proxy

Then use this middleware. This will only let things pass if the protocol is secure or if the requester is local. It will also return a positive health check to ELB. Otherwise, always redirect.

// security guard to make sure that the application is secure by default
app.use(function(req, res, next) {
if(req.protocol === 'https') {
return next();

var localdev = req.headers['host'] === 'localhost'; // flag for local development

if(localdev) {
return next();

// health ping from ELB
if (!req.connection.encrypted && !req.headers["x-forwarded-proto"]) {

// default does a redirect to the secure host
res.writeHead(301, {"Location": "https://" + req.headers['host'] + req.url});

dcm4chee installation on Windows

Java SE Development Kit 7u80 Java SE Development Kit 7u80 (jdk-7u80-windows-i586.exe)

Install MySQL

Download MySQL and install.

Create a blank database

> mysql -u root -p
mysql> create schema pacsdb;  
mysql> grant all on pacsdb.* to pacs@localhost identified by ‘pacs’;  
mysql> flush privileges;  
mysql> \q

Install Java JDK

Run jdk-7u80-windows-i586.exe

Install dcm4chee

extract o
copy content of 2.18.3 into 2.18.1 and overwrite any old files
delete server\default\deploydcm4chee-web-ear-3.0.5-mysql.ear
delete dcm4chee-2.18.3
rename the dcm4chee-2.18.1 directory back to dcm4chee-2.18.3

Install Database

> cd sql
> mysql -u root -p pacsdb < create.mysql

Install JBoss

Extract jboss to a directory

cd dcm4chee-2.18.1\bin
install_jboss.bat <directory of jboss>


> cd bin
> set JAVA_HOME=c:\Program Files (x86)\Java\jdk1.7.0_80\ (note the trailing slash and lack of quotes)
> run.bat



Default username is admin and password is admin

Trying to learn some front end web development…

Today, I was looking to see which front end web development technology I should learn. Here’s my summary.

Learn AngularJS! But wait, Angular 2.0 is about to come out. No React and Redux is much better, so learn that instead. Oh, you need to learn JSX, too. But it sucks! Learn Cycle.js instead. May be you should look into Elm. Forget all of that, let’s all rally behind open standard and learn ES6, and use webcomponents. What’s WebPack 2.0??? Don’t you know? Ember will make your app fast! If you are so inclined and like the Microsoft way, use TypeScript, and knockout.js. I haven’t mentioned Flux, Mithril, and Graphsql yet…

Javascript fatigue anyone? May be I should just learn jquery and write my own framework.