Node.js App Server AWS OpsWorks Stacks Layer - AWS OpsWorks

Node.js App Server AWS OpsWorks Stacks Layer


AWS OpsWorks Stacks is no longer accepting new customers. Existing customers will be able to use the OpsWorks console, API, CLI, and CloudFormation resources as normal until May 26, 2024, at which time they will be discontinued. To prepare for this transition, we recommend you transition your stacks to AWS Systems Manager as soon as possible. For more information, see AWS OpsWorks Stacks End of Life FAQs and Migrating your AWS OpsWorks Stacks applications to AWS Systems Manager Application Manager.


This layer is available only for Linux-based stacks.

The Node.js App Server layer is an AWS OpsWorks Stacks layer that provides a blueprint for instances that function as Node.js application servers. AWS OpsWorks Stacks also installs Express, so the layer's instances support both standard and Express applications.

Installation: Node.js is installed in /usr/local/bin/node.

The Add Layer page provides the following configuration options:

Node.js version

For a list of currently supported versions, see AWS OpsWorks Stacks operating systems.

Custom security groups

This setting appears if you chose to not automatically associate a built-in AWS OpsWorks Stacks security group with your layers. You must specify which security group to associate with the layer. For more information, see Create a New Stack.

Elastic Load Balancer

You can attach an Elastic Load Balancing load balancer to the layer's instances.


If your Node.js application uses SSL, we recommend that you disable SSLv3 if possible to address the vulnerabilities described in CVE-2015-8027. To do so, you must set Node.js version to 0.12.9.

Deploying Node.js Apps

For a detailed walkthrough of how to implement a simple Node.js application for AWS OpsWorks Stacks and deploy it to a stack, see Creating Your First Node.js Stack. In general, Node.js applications for AWS OpsWorks Stacks should meet the following conditions:

  • The main file must be named server.js and reside in the deployed application's root directory.

  • Express apps must include a package.json file in the application's root directory.

  • By default, the application must listen on port 80 (HTTP) or port 443 (HTTPS).

    It is possible to listen on other ports, but the Node.js App Server layer's built-in security group, AWS-OpsWorks-nodejs-App-Server, allows inbound user traffic only to ports 80, 443, and 22 (SSH). To allow inbound user traffic to other ports, create a security group with appropriate inbound rules and assign it to the Node.js App Server layer. Do not modify inbound rules by editing the built-in security group. Each time you create a stack, AWS OpsWorks Stacks overwrites the built-in security groups with the standard settings, so any changes that you make will be lost.


AWS OpsWorks Stacks sets the PORT environment variable to 80 (default) or 443 (if you enable SSL), so you can use the following code to listen for requests.


If you configure a Node.js app to support SSL, you must specify the key and certificates. AWS OpsWorks Stacks puts the data for each application server instance as separate files in the /srv/www/app_shortname/shared/config directory, as follows.

  • ssl.crt – the SSL certificate.

  • ssl.key – the SSL key.

  • – the chain certificate, if you have specified one.

Your application can obtain the SSL key and certificates from those files.