BT

NGINX Releases Open Source Web Server with Dynamic Configuration

| by Matt Campbell Follow 2 Followers on May 04, 2018. Estimated reading time: 2 minutes |

NGINX recently released version 1.0 of Unit, an open-source web and application server. The server supports remote and dynamic configuration and incurs no service interruptions 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.

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

The basic configuration requires at least one listener and one application. The listener details on which port and IP address Unit will listen to and redirect to a named application. An application definition allows for specification of the language, the directories for the application's files, and the number of processes.

For example, you can define 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 from Unit's documentation is to store this in a (version controlled) file and then post it to the server. If the data above 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/

Unit keeps the router process separate from the application processes, which run the application code. Each application process pool is run in its own sandbox to ensure isolation from other processes. This isolation permits multiple applications running in different languages to share the same server.

NGINX Unit architecture (credit: NGINX)

NGINX Unit architecture (credit: NGINX)

 

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

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

        "127.0.0.1:8600": {
            "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, head of products at NGINX, Unit is suitable for stand-alone or microservices-based architectures. It supports on-demand scaling of processes, executing each process in its own sandbox.

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

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

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT