News for hackers. Stuff that matters.
Re:Intro to Docker, React, and Security by praseodym on Monday January 21, 2019 @03:09AM (#18958625)
It is a bad idea to use a full-blown Node.js web server to serve some static content. A better solution would be to build the app in one container and then build another Nginx container to serve it. This container can then be hardened (run as non-root, use a read-only filesystem). An added benefit is that Nginx uses fewer system resources (~10 megabytes of RAM will work just fine).

We’re running such a setup in production; a sample Dockerfile can be found on https://github.com/WISVCH/docker-nginx.

Re:Intro to Docker, React, and Security by toomim on Monday January 21, 2019 @03:18AM (#18958672)
I know that nginx is more traditionally known for hosting static content than node.js, but are there any particular reasons why it's bad to just use node for static content these days?
Re:Intro to Docker, React, and Security by praseodym on Monday January 21, 2019 @04:29PM (#18963787)
From a security standpoint, the attack surface of Node.js and whatever libraries are used to make `npm start` happen is a lot larger than plain Nginx.

From a general usability standpoint, a Node.js container with all build dependencies will surely turn into a bloated several hundred megabyte Docker image — an Nginx image with just the built static files is a lot smaller.

Re:Intro to Docker, React, and Security by shishy on Tuesday January 22, 2019 @12:49AM (#18966263)
I understand you're comparing NodeJS vs Nginx there, but for my curiosity, if someone is building an API, how do you think NodeJS would compare to Ruby on Rails or Python/Django from a security standpoint?
Re:Intro to Docker, React, and Security by praseodym on Tuesday January 22, 2019 @05:31PM (#18973285)
I don’t think either language is fundamentally more secure than the other.

That being said, the Node.js ecosystem feels more immature than Python’s. The common practice of using microdependencies means that an average project has countless dependencies with varying levels of support — it’s all but impossible to make sure every one of those dependencies is properly maintained.

The framework/library churn rate seems to have decreased though, so that’s certainly good from a security standpoint as well.

Re:Intro to Docker, React, and Security by nunjee on Monday January 21, 2019 @03:38AM (#18958762)
It happened to me to have memory leaks and eventually OOM errors using Node.js as static files server. Switched then to Nginx...
Re:Intro to Docker, React, and Security by emilsedgh on Monday January 21, 2019 @06:34AM (#18959620)
Generally nginx is written in C which simply performs better than garbage collected, dynamically typed javascript.

But regarding sending static files, nginx uses Linux' sendFile[0] which outperforms anything in user-space.

Up until a few years ago this wasn't something Node could use. I'm not sure if still that's the case though. My information could be badly outdated.

[0] http://man7.org/linux/man-pages/man2/sendfile.2.html

Re:Intro to Docker, React, and Security by lowpro on Tuesday January 22, 2019 @02:01AM (#18966534)
Definitely agree! This project was put together in order to learn more about the technology itself, and much of this wouldn't be useful in production. For example our versioning was broken and we didn't figure out why, but that wouldn't be tenable either. We concluded for smaller projects Docker may be more trouble than it's worth, at least from a little experimenting with it. Thanks for the link!