Convienence utilities for building nginx configs


Dumps a string representation of a config. Accepts a list of config objects.

Parameters:config_list (list) – A list of config objects from this module
Return type:str
nginx.config.helpers.duplicate_options(key, values)[source]

There are many cases when building configs that you may have duplicate keys

This function will produce an EmptyBlock object with duplicate keys but unique values


from nginx.config.helpers import duplicate_options
from nginx.config.api import Location
loc = Location(
    duplicate_options('uwsgi_cache_valid', (['404', '5s'], ['200', '60s'])),

Which would produce:

location / {
    uwsgi_cache_valid 200 60s;
    uwsgi_cache_valid 404 5s;

Returns a simple nginx config.

Also serves as an example of how to build configs using this module.

Parameters:port (int) – A port to populate the ‘listen’ paramter of the server block
Rtype str: