Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Latest commit

 

History

History
260 lines (168 loc) · 6.48 KB

nginx_config_helper.md

File metadata and controls

260 lines (168 loc) · 6.48 KB

NginxModule

NginxModule(self, /, *args, **kwargs)

Enum of the valid NGINX modules.

Valid options are:

  • NginxModule.HTTP
  • NginxModule.STREAM

NginxConfigError

NginxConfigError(self, /, *args, **kwargs)

Exception to raise for errors in this module.

NginxBase

NginxBase(self)

NGINX base class.

CAUTION You can only use this class after the 'nginx-config.installed' flag is set !

backup_path

Path to the backup directory.

http_enabled_path

Path to the Http module include directory.

juju_app_name

Name of the juju application with unit number.

streams_enabled_path

Path to the Stream module include directory.

validate_nginx

NginxBase.validate_nginx(self)

Validates the NGINX configuration. Raises NginxConfigError when invalid.

Raises

NginxConfigError

reload_nginx

NginxBase.reload_nginx(self)

Reloads NGINX configuration. Raises NginxConfigError on error.

Raises

NginxConfigError

NginxMainConfig

NginxMainConfig(self)

Represents the nginx.conf file.

nginx_config

The nginx.conf file as a nginx.Conf object.

config_as_dict

NginxMainConfig.config_as_dict(self)

Returns the NGINX main config file as a dict.

config_as_object

NginxMainConfig.config_as_object(self)

Returns the NGINX main config file as a nginx.Conf object.

add_include

NginxMainConfig.add_include(self, include, nginx_module)

Adds an include value to the module.

Parameters

  • include (str): Include string.
  • nginx_module (NginxModule): NGINX module.

get_includes

NginxMainConfig.get_includes(self, nginx_module)

Return all includes values from a NGINX module.

Parameters

  • nginx_module (NginxModule): NGINX module.

Returns

list: A list containing all found include values.

add_module

NginxMainConfig.add_module(self, nginx_module)

Add a Http or Stream module to the NGINX config. If the module already exists, do nothing.

Parameters

  • nginx_module (NginxModule): NGINX module.

Raises

NginxConfigError

load_module

NginxMainConfig.load_module(self, nginx_cfg, nginx_module)

Return a module from the main NGINX config file.

Parameters

  • nginx_cfg (nginx.Conf): NGINX object
  • nginx_module (NginxModule): NGINX module.

Returns

nginx.Http or nginx.Stream

Raises

NginxConfigError

write_nginx_config

NginxMainConfig.write_nginx_config(self)

Writes the _nginx_config object to the nginx.conf file.

backup_nginx_config

NginxMainConfig.backup_nginx_config(self, dst=None)

Creates a copy of the nginx.conf file to the destination. Default to _backup_path if no destination is specified.

Parameters

  • dst (str or None): Destination path.

Raises

NginxConfigError

NginxConfig

NginxConfig(self)

Class for modifying NGINX configs.

base_path

Path to the layer directory.

http_available_path

Path to the sites-available directory.

layer

Name of the layer creating the class.

streams_available_path

Path to the streams-available directory.

write_config

NginxConfig.write_config(self, nginx_module, config, filename, subdir=None)

Writes the config to the nginx_module available dir.

Parameters

  • nginx_module (NginxModule): NGINX module.
  • config (str): NGINX config to be written.
  • filename (str): Name of the config file.
  • subdir (str or None): If specified, the value of subdir will be appended to the available_path variable. Use this if you want to write the config to a self made directory.

Raises

NginxConfigError

enable_all_config

NginxConfig.enable_all_config(self, nginx_module, subdir=None)

Creates symb links in the nginx_module enabled dir for all files in the available directory.

Parameters

  • nginx_module (NginxModule): NGINX module.
  • subdir (str or None): If specified, the value of subdir will be appended to the available_path variable. Use this if you wrote configs to a seperate directory.

Raises

NginxConfigError

delete_all_config

NginxConfig.delete_all_config(self, nginx_module, subdir=None)

Delete all symb links and configs from the nginx_module.

Parameters

  • nginx_module (NginxModule): NGINX module.
  • subdir (str or None): If specified, the value of subdir will be appended to the available_path variable. Use this if you don't want to delete all configs in the available directory but instead a self made subdir.

Raises

NginxConfigError