NGINX launches open source web server with dynamic configuration

NGINX recently released version 1.0 of Unit, an open source web and application server. The server supports remote and dynamic configuration and does not experience any downtime for configuration changes. Unit 1.0 also supports multiple languages ​​(Go, Perl, PHP, Python, and Ruby) running on the same instance, including multiple versions of the same language.

The NGINX unit does not rely on a static configuration file, but rather is configured via a REST API using JSON. All configuration is stored directly in memory, allowing changes to be made without restarting running services. The router process is persistent and does not require a restart.

The basic setup requires at least one listener and one app. The listener details the port and IP address that the unit will listen to and redirect to a named application. An application definition allows you to specify the language, the directories of the application files and the number of processes.

For example, you can set a listener on port 8300 to serve a PHP application located in / www / blogs / scripts using up to 20 processes:

    "listeners": {
        "*:8300": {
            "application": "blogs"

    "applications": {
        "blogs": {
            "type": "php",
            "processes": 20,
            "root": "/www/blogs/scripts",
            "index": "index.php"

The recommendation of Unit documentation is to store it in a file (controlled version), then publish it on the server. If the above data is stored in a file called start.json, an initial configuration can be created as follows:

# curl -X PUT -d @/path/to/start.json --unix-socket /path/to/control.unit.sock http://localhost/

The unit keeps the router process separate from the application processes, which execute the application code. Each application process pool runs in its own sandbox to ensure isolation from other processes. This isolation allows multiple applications running in different languages ​​to share the same server.

Architecture of the NGINX unit (credit: NGINX)

In the following example, a Go application and a Perl application are configured to run on the same Unit server:

    "listeners": {
       "*:8500": {
            "application": "go_chat_app"

        "": {
            "application": "bugtracker"

    "applications": {
        "go_chat_app": {
            "type": "go",
            "user": "www-chat",
            "group": "www-chat",
            "working_directory": "/www/chat",
            "executable": "bin/chat_app"
        "bugtracker": {
            "type": "perl",
            "processes": 3,
            "user": "www",
            "group": "www",
            "working_directory": "/www/bugtracker",
            "script": "app.psgi"
        }    }

According to Owen Garrett, Product Manager at NGINX, Unit is suitable for stand-alone or microservice-based architectures. It supports on-demand process scaling, running each process in its own sandbox.

NGINX plans to add language support for Java and Node.js in a future release. The company plans to support SSL and HTTP / 2, as well as support for static content and routing using URIs and hostnames.

The NGINX unit is Open source (Apache License 2.0) and there is pre-built packages available for most operating systems, including Debian, CentOS, Ubuntu, and others. There is also Docker container available on Docker Hub.

Source link

Comments are closed.