Skip to main content

DDD nginx framework for python

Project description

DDD Nginx Framework

Build Status Pypi Status Coveralls Status

Installation

From source code:

python setup.py install

From pypi:

pip install ddd-base

Usage

from ddd_nginx.nginx import Nginx
from ddd_nginx.map import Map, MapKeyParis, MapDefinition
from ddd_nginx.server import Server
from ddd_nginx.location import Location, ReverseProxyStrategy
from ddd_nginx.upstream import Upstream


nginx = Nginx(host="oneapi.cc")
nginx.namespace = "api"

a_map = Map(MapDefinition(key="$http_apikey", value="$api_client_name"))
a_map.append(MapKeyParis("7B5zIqmRGXmrJTFmKa99vcit", "client_one"))
a_map.append(MapKeyParis("QzVV6y1EmQFbbxOfRCwyJs35", "client_two"))
a_map.append(MapKeyParis("mGcjH8Fv6U9y3BVF9H3Ypb9T", "client_six"))

a_upstream = Upstream(name="warehouse_inventory")
a_upstream.append("10.0.0.1:80")
a_upstream.append("10.0.0.2:80")
a_upstream.append("10.0.0.3:80")

b_upstream = Upstream(name="warehouse_pricing")
b_upstream.append("10.0.0.1:80")
b_upstream.append("10.0.0.2:80")
b_upstream.append("10.0.0.3:80")

a_location = Location(
    name="/api/warehouse/inventory",
    proxy=ReverseProxyStrategy('rewrite', '^ /_warehouse last')
)
a_location.set_var("$upstream", "warehouse_inventory")
b_location = Location(
    name="/api/warehouse/pricing",
    proxy=ReverseProxyStrategy('rewrite', '^ /_warehouse last')
)
b_location.set_var("$upstream", "warehouse_pricing")
c_location = Location(
    name="= /_warehouse",
    proxy=ReverseProxyStrategy('proxy_pass', 'http://$upstream$request_uri'),
    scope="internal"
)
c_location.set_var("$api_name", "Warehouse")

a_server = Server(name=nginx.namespace)
a_server.set_var("$api_name", "-")

nginx.append(a_map)
nginx.append(a_upstream)
nginx.append(b_upstream)
nginx.append(a_location)
nginx.append(b_location)
nginx.append(c_location)
nginx.append(a_server)

root_dir = "./dumps_dir"
nginx.dumps(root_dir)

License

This software is licensed under the MIT license

See License file

Changelog

0.1.2

  • Template exposed

0.1.1

  • Add server to support tls or not

0.1.0

  • Provide all in one configure file

0.0.8

  • Include template files

0.0.7

  • Include jinja2 templates

0.0.6

  • Add json error page configuration file

0.0.5

  • Add coverage

0.0.4

  • Clear dependency

0.0.3

  • Dumps nginx to files

0.0.2

  • Render conf with template

0.0.1

  • Initial public release

Project details


Download files

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

Source Distribution

ddd-nginx-0.1.2.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file ddd-nginx-0.1.2.tar.gz.

File metadata

  • Download URL: ddd-nginx-0.1.2.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for ddd-nginx-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e617f89e4a2ca2235b051eac87dc9ef9aa72b777f3331b6d3a489fee7e662d08
MD5 3c655e7777cab53812cd5d8eb66cb562
BLAKE2b-256 f64a98ded2abaf752e30ad6a4f47e41c00bcb73b8ab14b3302a6cc415a43e31a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page