Guru
Guru

Reputation: 11

Why does nginx need Lua when it works fine without it?

Why does nginx need Lua when it works fine without Lua and Openresty?

Also, I'd like to know which Lua modules are very important to build large scale web applications.

Upvotes: 1

Views: 1283

Answers (1)

DarkWiiPlayer
DarkWiiPlayer

Reputation: 7064

Okay, those are two questions.

Why does nginx need Lua

Well, it doesn't need it; in fact, many people are using plain nginx just fine. Even though I usually just run openresty, I often find myself doing lots of things with just the nginx features.

That being said, Lua is a scripting language, something that nginx on its own jus doesn't (yet) have. It allows adding functionality to a webserver without having to write C modules and in a way that can be easily changed or reloaded during runtime.

Kong is a good example for this: It uses Lua to script advanced behavior that nginx doesn't really support out of the box.

which Lua modules are very important to build large scale web applications

That really depends on what you want to build. In principle, you can build lots of stuff just with openresty alone, and if you do it right, it will probably be faster than most applications written in other frameworks.

Normally, you'd most likely want at least some sort of templating engine though. Something that allows you to build HTML pages without having to rely on Luas "primitive" string processing features. You will also most likely need some library to interface whatever database you decide to use. From there it really depends mostly on what you want to build.

Upvotes: 1

Related Questions