• Stars
    star
    310
  • Rank 134,259 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created almost 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An nginx module to resolve domain names inside upstreams and keep them up to date.

nginx-upstream-dynamic-servers

An nginx module to resolve domain names inside upstreams and keep them up to date.

By default, servers defined in nginx upstreams are only resolved when nginx starts. This module provides an additional resolve parameter for server definitions that can be used to asynchronously resolve upstream domain names. This keeps the upstream definition up to date according to the DNS TTL of each domain names. This can be useful if you want to use upstreams for dynamic types of domain names that may frequently change IP addresses.

This module also allows nginx to start if an upstream contains a defunct domain name that no longer resolves. By default, nginx will fail to start if an upstream server contains an unresolvable domain name. With this module, nginx is still allowed to start with invalid domain names, but an error will be logged and the unresolvable domain names will be marked as down.

Installation

./configure --add-module=/path/to/nginx-upstream-dynamic-servers
make && make install

Usage

Use the server definition inside your upstreams and specify the resolve parameter.

Note: A resolver must be defined at the http level of nginx's config for resolve to work.

http {
  resolver 8.8.8.8;

  upstream example {
    server example.com resolve;
  }
}

Directives

server

Syntax: server address [parameters];
Context upstream

Defines a server for an upstream. The module adds the ability to specify a resolve parameter. When specified:

  • Domain names will be resolved on an ongoing basis and kept up to date according to the TTL of each domain name.
  • Unresolvable domain names are considered non-fatal errors (but logged). nginx is allowed to startup if a domain name can't be resolved, but the server is marked as down.

The following parameters can be used (see nginx's server documentation for details):

weight=number
max_fails=number
fail_timeout=time
backup
down
resolve

Compatibility

Tested with nginx 1.6, 1.7, 1.8, 1.9.

Alternatives

  • proxy_pass + resolver: If you only need to proxy to 1 domain and don't need the additional capabilities of upstreams, nginx's proxy_pass can perform resolving at run-time.
  • ngx_upstream_jdomain: An nginx module that asyncronously resolves domain names. The primary differences between jdomain and this module is that this module keeps domain names up to date even if no server traffic is being generated (jdomain requires traffic to each upstream in order to keep it up to date). This module also allows nginx to startup if unresolvable domain names are given.
  • tengine's dynamic_resolve: If you're using tengine (an nginx fork), there's a new feature (currently unreleased) to support resolving domain names in upstreams at run-time.
  • NGINX Plus

License

nginx-upstream-dynamic-servers is open sourced under the MIT license.

More Repositories

1

covid-vaccine-spotter

JavaScript
523
star
2

lua-resty-mail

A high-level, easy to use, and non-blocking email and SMTP library for OpenResty.
Lua
60
star
3

lua-libcidr-ffi

LuaJIT FFI bindings to libcidr. Provides CIDR calculations for IPv4 and IPv6.
Lua
47
star
4

lua-docker

Minimal, automated, and up-to-date Docker images for different Lua and LuaJIT versions.
Dockerfile
47
star
5

after_commit

A Ruby on Rails plugin to add an after_commit callback. Official fork with gem is now at:
Ruby
43
star
6

uas-parser

A user agent string parser for Node.js. Uses data from user-agent-string.info.
JavaScript
22
star
7

postgis-docker

Automated and up-to-date Docker images for all supported versions of PostgreSQL, PostGIS, and pgRouting.
Shell
20
star
8

gettext-vue

Extract translatable strings from Vue files
JavaScript
16
star
9

http-stale-cache-proxy

A non-compliant HTTP caching proxy that excels at serving stale cached content, while keeping its cache updated asynchronously.
JavaScript
15
star
10

lua-shell-games

A Lua library to help execute shell commands more easily and safely.
Lua
13
star
11

lua-icu-date-ffi

Lua
9
star
12

lua-resty-txid

Generate sortable, unique transaction or request IDs for OpenResty/nginx.
Lua
8
star
13

carrierwave-postgresql-table

Store CarrierWave files in PostgreSQL (supporting multiple versions per uploader).
Ruby
6
star
14

activerecord-postgres-dump-schemas

Define which PostgreSQL schemas to dump in your Rails db/structure.sql file
Ruby
5
star
15

bunyan-rollbar

A Bunyan stream plugin to send error logs to Rollbar
JavaScript
5
star
16

vault_env_secrets

Load secrets from Vault into environment variables (via consul-template config and with Rails integration)
Ruby
2
star
17

TS-3959

Scripts to demonstrate https://issues.apache.org/jira/browse/TS-3959
Ruby
2
star
18

fast_excel_rails

A Rails template handler for the fast_excel gem.
Ruby
2
star
19

legacy-rails-CVE-2020-5267-patch

Patch CVE-2020-5267 for Rails 4 and Rails 3
Ruby
2
star
20

secret_keys_rails

Git-friendly encrypted secrets for Rails.
Ruby
2
star
21

covid-vaccine-finder-website-data

1
star
22

postcss-relative-rem

A postcss plugin to convert rem units to units relative a CSS variable (instead of the root element's font size).
JavaScript
1
star
23

lua-openssl-ffi

Lua
1
star