nginx-reverse-proxy-vhost-config

Description

TOOD: documentation, examples

Variables

Name Type Default Description

path

string --

The path to the file. Required

proxy_url

string --

The url to proxy. Required

access_log

string --

The access log.

error_log

string --

The error log path and (optional) log level.

proxy_options

list --

A list of options to set in the proxy location block.

server_admin

string --

The server admin email.

server_names

list ['localhost']

The server names.

use_https

boolean False

Whether to use https.

All http traffic will be redirected to https.

Code

doc:
  short_help: Create Nginx server block configuration file for a reverse proxy.
  help: |
    TOOD: documentation, examples

args:
  proxy_url:
    doc:
      short_help: The url to proxy.
    required: true
    type: string
  proxy_options:
    doc:
      short_help: A list of options to set in the proxy location block.
    type: list
    schema:
      type: string
#    empty: true
    required: false
#    default: []
    cli:
      metavar: OPTION_LINE
      param_decls:
      - --proxy-option
  use_https:
    doc:
      short_help: Whether to use https.
      help: |
        Whether to use https.

        All http traffic will be redirected to https.
    type: boolean
    required: false
    default: false
  server_admin:
    doc:
      short_help: The server admin email.
    type: string
    required: false
    cli:
      metavar: EMAIL
  server_names:
    doc:
      short_help: The server names.
      references:
      - '[Nginx server documentation](https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/#wildcard-subdomains-in-a-parent-folder)'
    type: list
    required: true
    empty: false
    schema:
      type: string
    default:
    - localhost
    cli:
      param_decls:
      - --server-name
      - -n
  access_log:
    doc:
      short_help: The access log.
    type: string
    required: false
    cli:
      metavar: PATH
  error_log:
    doc:
      short_help: The error log path and (optional) log level.
      references:
      - '[Nginx core documentation](http://nginx.org/en/docs/ngx_core_module.html#error_log)'
    type: string
    required: false
    cli:
      metavar: PATH

frecklets:
- nginx-server-block-file:
    path: '{{:: path ::}}'
    use_https: '{{:: use_https ::}}'
    server_admin: '{{:: server_admin ::}}'
    access_log: '{{:: access_log ::}}'
    error_log: '{{:: error_log ::}}'
    server_names: '{{:: server_names ::}}'
    owner: root
    location_blocks:
    - location_match: /
      properties: |
        proxy_pass {{:: proxy_url ::}};
        {%:: for h in proxy_options ::%}
        {%:: if h ::%}{{:: h ::}}{%:: endif ::%}{%:: if not h.endswith(";") ::%};{%:: endif ::%}
        {%:: endfor ::%}
frecklecute nginx-reverse-proxy-vhost-config --help

Usage: frecklecute nginx-reverse-proxy-vhost-config [OPTIONS] PATH

  TOOD: documentation, examples

Options:
  --proxy-url PROXY_URL           The url to proxy.  [required]
  --access-log PATH               The access log.
  --error-log PATH                The error log path and (optional) log level.
  --proxy-option OPTION_LINE      A list of options to set in the proxy
                                  location block.
  --server-admin EMAIL            The server admin email.
  -n, --server-name SERVER_NAMES  The server names.
  --use-https / --no-use-https    Whether to use https.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.nginx_reverse_proxy_vhost_config.NginxReverseProxyVhostConfig
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class NginxReverseProxyVhostConfig(AutoPycklet):
    """TOOD: documentation, examples

       Args:
         access_log: The access log.
         error_log: The error log path and (optional) log level.
         path: The path to the file.
         proxy_options: A list of options to set in the proxy location block.
         proxy_url: The url to proxy.
         server_admin: The server admin email.
         server_names: The server names.
         use_https: Whether to use https.

    """

    FRECKLET_ID = "nginx-reverse-proxy-vhost-config"

    access_log: str = None
    error_log: str = None
    path: str = None
    proxy_options: List = None
    proxy_url: str = None
    server_admin: str = None
    server_names: List = None
    use_https: bool = None


    def __post_init__(self):
        super(NginxReverseProxyVhostConfig, self).__init__(var_names=["access_log", "error_log", "path", "proxy_options", "proxy_url", "server_admin", "server_names", "use_https"])


frecklet_class = NginxReverseProxyVhostConfig
# -*- coding: utf-8 -*-


#
# module path: pycklets.nginx_reverse_proxy_vhost_config.NginxReverseProxyVhostConfig
#


from pyckles import AutoPycklet

class NginxReverseProxyVhostConfig(AutoPycklet):
    """TOOD: documentation, examples

       Args:
         access_log: The access log.
         error_log: The error log path and (optional) log level.
         path: The path to the file.
         proxy_options: A list of options to set in the proxy location block.
         proxy_url: The url to proxy.
         server_admin: The server admin email.
         server_names: The server names.
         use_https: Whether to use https.

    """

    FRECKLET_ID = "nginx-reverse-proxy-vhost-config"

    def __init__(self, access_log=None, error_log=None, path=None, proxy_options=None, proxy_url=None, server_admin=None, server_names=['localhost'], use_https=None):

        super(NginxReverseProxyVhostConfig, self).__init__(var_names=["access_log", "error_log", "path", "proxy_options", "proxy_url", "server_admin", "server_names", "use_https"])
        self._access_log = access_log
        self._error_log = error_log
        self._path = path
        self._proxy_options = proxy_options
        self._proxy_url = proxy_url
        self._server_admin = server_admin
        self._server_names = server_names
        self._use_https = use_https

    @property
    def access_log(self):
        return self._access_log

    @access_log.setter
    def access_log(self, access_log):
        self._access_log = access_log

    @property
    def error_log(self):
        return self._error_log

    @error_log.setter
    def error_log(self, error_log):
        self._error_log = error_log

    @property
    def path(self):
        return self._path

    @path.setter
    def path(self, path):
        self._path = path

    @property
    def proxy_options(self):
        return self._proxy_options

    @proxy_options.setter
    def proxy_options(self, proxy_options):
        self._proxy_options = proxy_options

    @property
    def proxy_url(self):
        return self._proxy_url

    @proxy_url.setter
    def proxy_url(self, proxy_url):
        self._proxy_url = proxy_url

    @property
    def server_admin(self):
        return self._server_admin

    @server_admin.setter
    def server_admin(self, server_admin):
        self._server_admin = server_admin

    @property
    def server_names(self):
        return self._server_names

    @server_names.setter
    def server_names(self, server_names):
        self._server_names = server_names

    @property
    def use_https(self):
        return self._use_https

    @use_https.setter
    def use_https(self, use_https):
        self._use_https = use_https



frecklet_class = NginxReverseProxyVhostConfig