BT

InfoQ Homepage News NGINX Unit Adds Support for Reverse Proxying and Address-Based Routing

NGINX Unit Adds Support for Reverse Proxying and Address-Based Routing

Bookmarks

NGINX announced the release of versions 1.13 and 1.14 of NGINX Unit, its open-source web and application server. These releases include support for reverse proxying and address-based routing based on the connected client's IP address and the target address of the request.

NGINX Unit is able to run web applications in multiple language versions simultaneously. Languages supported include Go, Perl, PHP, Python, Node.JS, Java, and Ruby. The server does not rely on a static configuration file, instead allowing for configuration via a REST API using JSON. Configuration is stored in memory allowing for changes to happen without a restart.

With these latest releases, NGINX Unit now offers support for reverse proxying. A reverse proxy sits in front of the web servers and forwards client requests to those servers. The new proxy option has been added to the general routing framework and allows for proxying of requests to a specified address. At this time, the proxy address configuration has support for IPv4, IPv6, and Unix socket addresses.

For example, the routes object below will proxy the request to 127.0.0.1:8000 in the event that the incoming request matches the match condition:

{
  "routes": [
    {
      "match": {
        "host": "v1.example.com"
      },

      "action": {
        "proxy": "http://127.0.0.1:8000"
      }
    }
  ]
}

The proxy option joins the previously added pass and share actions for determining how to route traffic. The pass option, added in version 1.8.0, allows for internal routing of traffic by either passing requests to an application or a route. Internal routing is beneficial in cases where certain requests should be handled by separate applications, such as incorrect requests being passed off to a seperate application for handling in order to minimize impact on the main application.

The share action, added in version 1.11.0, allows for the sharing of static files. This includes support for encoded symbols in URIs, a number of built-in MiME types, and the ability to add additional types.

Address-based routing was added with the 1.14 release. It enables address matching against two new match options: source and destination. The source match option allows for matching based on the connected client's IP address, while the destination option matches the target address of the request.

Also with this release, the routing engine can now match address values against IPv4- and IPv6-based patterns and arrays of patterns. These patterns can be wildcards with port numbers, exact addresses, or CIDR notation. In the example below, requests with a source and address that matches the CIDR notation will provide access to the resources within the share path.

{
  "routes": [
    {
      "match": {
        "source": [
          "10.0.0.0/8", 
          "10.0.0.0/7:1000",
          "10.0.0.0/32:8080-8090"
        ]
      },

      "action": {
        "share": "/www/data/static/"
      }
    }
  ]
}

If the /www/data/static/ directory has the following structure:

/www/data/static/
├── stylesheet.css
├── html
│  └──index.html
└── js files
   └──page.js

Then a request such as curl 10.0.0.168:1000/html/index.html will serve the index.html file.

Artem Konev, senior technical writer for F5 Networks, indicates that future releases of NGINX Unit should include round-robin load balancing, rootfs support to further enhance application isolation, improved logic for handling static assets, and memory performance improvements.

NGINX Unit is available for download on GitHub. Support for NGINX Unit is provided with NGINX Plus. For more details on changes in the release, please review the NGINX Unit changelog.

Rate this Article

Adoption
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.

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

Community comments

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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.