This module provides high-level tools for installing the nginx web server and managing the configuration of web sites.
Require nginx server to be installed and running. Allows override of package name, this allow to install other packages like nginx-extras or nginx-light.
from fabtools import require
require.nginx.server()
Ensure link to /etc/nginx/sites-available/config exists and reload nginx configuration if needed.
Ensure link to /etc/nginx/sites-available/config doesn’t exist and reload nginx configuration if needed.
Require an nginx site.
You must provide a template for the site configuration, either as a string (template_contents) or as the path to a local template file (template_source).
from fabtools import require
CONFIG_TPL = '''
server {
listen %(port)d;
server_name %(server_name)s %(server_alias)s;
root %(docroot)s;
access_log /var/log/nginx/%(server_name)s.log;
}'''
require.nginx.site('example.com', template_contents=CONFIG_TPL,
port=80,
server_alias='www.example.com',
docroot='/var/www/mysite',
)
Require an nginx site for a proxied app.
This uses a predefined configuration template suitable for proxying requests to a backend application server.
Required keyword arguments are:
from fabtools import require
require.nginx.proxied_site('example.com',
port=80,
proxy_url='http://127.0.0.1:8080/',
docroot='/path/to/myapp/static',
)