Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Dinamically route to localhost request for uWSGI locally subscribed domains.

Project description

# uWSGI-local-DNS-resolver
uWSGI-local-DNS-resolver (from now on __uWSGI-DNS__) is a DNS server that resolves to `localhost` each request directed to a uWSGI-subscribed domain.

# Why?
Our main intent is to let users transparently connect to their local development instances handled through a uWSGI HTTP subscription server.

## Project status
uWSGI-DNS is still a work in progress. As a consequence, its APIs could be subject to changes.

## Features
- Python 2 & Python 3 compatibility.
- UNIX/Linux systems compatibility.
- Automatic domain refresh on new uWSGI subscriptions.
- Failed nodes detection and handling.

## Installation
Until uWSGI-DNS lands on PyPi you can install it as follows:
$ git clone
$ cd uwsgi-local-dns-resolver
$ python install # you could need sudo here

And if you want, you can test the server with:
$ sudo uwsgidns # we need sudo to bind on reserved port 53

Once started, you should have a DNS server running on `localhost:53`.

Note: installing uWSGI-DNS inside a virtualenv is obviously possible, but you should use particular care while integrating it into uWSGI configuration files.

## Configuration
$ uwsgidns -h
usage: uwsgidns [-h] [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG,NOTSET}] [-p]
[-u upstream DNS server URI] [-s uwsgi-HTTP-stats-URI]

DNS server that resolves to localhost uWSGI HTTP subscribed domains.

optional arguments:
-h, --help show this help message and exit
set the logging level
-p, --proxy proxy other requests to upstream DNS server
-u upstream DNS server URI, --upstream upstream DNS server URI
the URI to the upstream DNS server (with --proxy),
defaults to
-s uwsgi-HTTP-stats-URI, --stats uwsgi-HTTP-stats-URI
the URI (remote:port) to the uWSGI HTTP subscription
stats server

### Non-local requests
uWSGI-DNS can act as a DNS proxy (`-p`), forwarding each non-local request to the upstream server specified with the `-u` flag;
otherwise, it simply drops such requests and let the OS fallback DNS server handle them.

### uWSGI stats
Setting the `-s` will let uWSGI-DNS poll the uWSGI subscription server periodically.
In this way uWSGI-DNS will notice failed/disappeared HTTP nodes and will remove them from the local domains.

## uWSGI (Emperor) integration
The integration with the uWSGI emperor is simple and straightforward.
We assume you use the uWSGI HTTP subscription server.
To integrate uWSGI-DNS you can edit the configuration file of your emperor/subscription server as follows:

; uWSGI subscription server - ini configuration file
http = :80
http-subscription-server =
http-stats-server =

; resubscribe let uWSGI-DNS know about new HTTP nodes
http-resubscribe =

; launch the uWSGI-DNS with the HTTP subscription server
; you can tweak the command line arguments and the path here
attach-daemon = uwsgidns
Anytime you'll launch the subscription system, the uWSGI-DNS server will launch with it.

Please note that in the following section we provide some more OS-specific examples.

## OS integration
TODO: other OSs integration.

The OS integration largely varies with each platforms.
We provide here just a few examples, adapt them to your needs.

### OS X integration
You can use LaunchD to automatically launch a uWSGI emperor instance on startup.
To do so, create the file `it.unbit.uwsgi.emperor.plist` in the `/Library/LaunchDaemons/` directory and make sure it has the following content.
The same example can also be found in this repository.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<!-- You could either need or not some more plugins,
if you're using a monolitic uWSGI build -->
<string>/usr/local/bin/uwsgidns -p</string>
Put the vassals configuration files in your home folder and then start the uWSGI emperor with the command:
$ sudo launchctl load /Library/LaunchDaemons/it.unbit.uwsgi.emperor.plist

You can finally edit your connection parameters and set the [custom DNS server]( pointing to ``.
The DNS resolver will try to solve local requests and then will proxy to upstream the others.
The default upstream is `` and you can customize it with the `-u UPSTREAM_ADDRESS:PORT` flag.

_Bonus_: before editing your network settings, you can create a new [Network Location]( to be specifically used while developing and edit its DNS settings.

## Tests
TODO: add tests.

Project details

Release history Release notifications

This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
uwsgidns-1.0.1.tar.gz (11.7 kB) Copy SHA256 hash SHA256 Source None Jun 5, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page