dgtlmoon/nginx-sql-proxypass-resolver

An experimental DNS server to act as a `resolver` for nginx to bounce your requests to depending on the SQLite lookup data

9

stars

16

commits

Python

primary language

Mar 12, 2026

updated

README

Experimental DNS server to act as a proxy_pass resolver for nginx to bounce your requests to depending on SQLite lookup data

Experimental Python based DNS server that lets you use SQLite as a nginx proxy_pass resolver that performs an SQLite query to decide where to resolve/pass proxy_pass the request to.

( Asks a SQLite DB what the real IP for a lookup should be and returns that so proxy_pass can use it )

Based on https://github.com/paulc/dnslib/blob/master/dnslib/fixedresolver.py

docker-compose up

Then

Configuration

All settings are environment variables:

VariableDefaultDescription
DATABASE_URLsqlite:////data.dbSQLAlchemy connection URL. Supports SQLite, MySQL, PostgreSQL.
SQL_QUERYSELECT dest_addr FROM lookup WHERE name IS NOT NULL AND name LIKE :nameQuery to resolve a name. Must use :name as the named parameter.
DNS_TTL60TTL (seconds) for DNS responses and cache entries.
CACHE_SIZE512Max number of cached entries (LRU eviction).
UPSTREAM_DNS127.0.0.11Fallback DNS server for names not found in the DB (Docker embedded DNS).
UPSTREAM_PORT53Port for the upstream DNS server.
LOOKUP_TIMEOUT3.0Timeout in seconds for upstream DNS queries.

Backend examples

# SQLite (default)
DATABASE_URL=sqlite+aiosqlite:////data.db

# MySQL
DATABASE_URL=mysql+asyncmy://user:pass@mysql-host/dbname

# PostgreSQL
DATABASE_URL=postgresql+asyncpg://user:pass@pg-host/dbname

Install the matching async driver via requirements.txt (see comments in that file).

See

Note

Use at own risk, may or may not scale, may or may not rename your dog and set your house on fire.

Contributors

dgtlmoon

16 commits

dgtlmoon/nginx-sql-proxypass-resolver

An experimental DNS server to act as a `resolver` for nginx to bounce your requests to depending on the SQLite lookup data

9

stars

16

commits

Python

primary language

Mar 12, 2026

updated

README

Experimental DNS server to act as a proxy_pass resolver for nginx to bounce your requests to depending on SQLite lookup data

Experimental Python based DNS server that lets you use SQLite as a nginx proxy_pass resolver that performs an SQLite query to decide where to resolve/pass proxy_pass the request to.

( Asks a SQLite DB what the real IP for a lookup should be and returns that so proxy_pass can use it )

Based on https://github.com/paulc/dnslib/blob/master/dnslib/fixedresolver.py

docker-compose up

Then

Configuration

All settings are environment variables:

VariableDefaultDescription
DATABASE_URLsqlite:////data.dbSQLAlchemy connection URL. Supports SQLite, MySQL, PostgreSQL.
SQL_QUERYSELECT dest_addr FROM lookup WHERE name IS NOT NULL AND name LIKE :nameQuery to resolve a name. Must use :name as the named parameter.
DNS_TTL60TTL (seconds) for DNS responses and cache entries.
CACHE_SIZE512Max number of cached entries (LRU eviction).
UPSTREAM_DNS127.0.0.11Fallback DNS server for names not found in the DB (Docker embedded DNS).
UPSTREAM_PORT53Port for the upstream DNS server.
LOOKUP_TIMEOUT3.0Timeout in seconds for upstream DNS queries.

Backend examples

# SQLite (default)
DATABASE_URL=sqlite+aiosqlite:////data.db

# MySQL
DATABASE_URL=mysql+asyncmy://user:pass@mysql-host/dbname

# PostgreSQL
DATABASE_URL=postgresql+asyncpg://user:pass@pg-host/dbname

Install the matching async driver via requirements.txt (see comments in that file).

See

Note

Use at own risk, may or may not scale, may or may not rename your dog and set your house on fire.

Contributors

dgtlmoon

16 commits

Languages

Python

84.5%

Shell

12.6%

Dockerfile

2.8%