---
title: Charmhub | Deploy Nginx Ingress Integrator using Charmhub - The Open Operator
  Collection
description: Deploy the latest version of Nginx Ingress Integrator on any cloud.
url: https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route
---

# Nginx Ingress Integrator

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

22.04

20.04

stable 203

```
juju deploy nginx-ingress-integrator
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route#drawer)

## charms.nginx\_ingress\_integrator.v0.nginx\_route

* [*Docstrings*Docstrings](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route)
  [*Code*Source code](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.nginx_ingress_integrator.v0.nginx_route
    ```

    [Download nginx\_route.py](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route/download)
  + *Last updated* 07 May 2024
  + *Revision* Library version 0.7

Library for the nginx-route relation.

This library contains the require and provide functions for handling
the nginx-route interface.

Import `require_nginx_route` in your charm, with four required keyword arguments:

* charm: (the charm itself)
* service\_hostname
* service\_name
* service\_port

Other optional arguments include:

* additional\_hostnames
* backend\_protocol
* limit\_rps
* limit\_whitelist
* max\_body\_size
* owasp\_modsecurity\_crs
* owasp\_modsecurity\_custom\_rules
* path\_routes
* retry\_errors
* rewrite\_target
* rewrite\_enabled
* service\_namespace
* session\_cookie\_max\_age
* tls\_secret\_name

See [the config section](https://charmhub.io/nginx-ingress-integrator/configure) for descriptions
of each, along with the required type.

As an example, add the following to `src/charm.py`:

```
from charms.nginx_ingress_integrator.v0.nginx_route import NginxRouteRequirer

# In your charm's `__init__` method (assuming your app is listening on port 8080).
require_nginx_route(
    charm=self,
    service_hostname=self.app.name,
    service_name=self.app.name,
    service_port=8080
)
```

And then add the following to `metadata.yaml`:

```
requires:
  nginx-route:
    interface: nginx-route
```

You *must* require nginx route as part of the `__init__` method
rather than, for instance, a config-changed event handler, for the relation
changed event to be properly handled.

In the example above we're setting `service_hostname` (which translates to the
external hostname for the application when related to nginx-ingress-integrator)
to `self.app.name` here. This ensures by default the charm will be available on
the name of the deployed juju application, but can be overridden in a
production deployment by setting `service-hostname` on the
nginx-ingress-integrator charm. For example:

```
juju deploy nginx-ingress-integrator
juju deploy my-charm
juju relate nginx-ingress-integrator my-charm:nginx-route
# The service is now reachable on the ingress IP(s) of your k8s cluster at
# 'http://my-charm'.
juju config nginx-ingress-integrator service-hostname='my-charm.example.com'
# The service is now reachable on the ingress IP(s) of your k8s cluster at
# 'http://my-charm.example.com'.
```

---

Index

* [class NginxRouteRequirer](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route#nginxrouterequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    config,
    nginx\_route\_relation\_name)](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route#nginxrouterequirer-__init__)
* [def require\_nginx\_route(
  )](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route#require_nginx_route)
* [def provide\_nginx\_route(
  charm,
  on\_nginx\_route\_available,
  on\_nginx\_route\_broken,
  nginx\_route\_relation\_name
  )](https://charmhub.io/nginx-ingress-integrator/libraries/nginx_route#provide_nginx_route)

#### class NginxRouteRequirer

This class defines the functionality for the 'requires' side of the 'nginx-route' relation.

Description

Hook events observed:
- relation-changed

Methods

NginxRouteRequirer.
\_\_init\_\_(

*self*

,
charm

,
config

,
nginx\_route\_relation\_name: str
)

Init function for the NginxRouteRequires class.

Arguments

charm

The charm that requires the nginx-route relation.

config

Contains all the configuration options for nginx-route.

nginx\_route\_relation\_name

Specifies the relation name of the relation handled by this
requirer class. The relation must have the nginx-route interface.

#### def require\_nginx\_route()

Set up nginx-route relation handlers on the requirer side.

Arguments

charm

The charm that requires the nginx-route relation.

service\_hostname

configure Nginx ingress integrator
service-hostname option via relation.

service\_name

configure Nginx ingress integrator service-name
option via relation.

service\_port

configure Nginx ingress integrator service-port
option via relation.

additional\_hostnames

configure Nginx ingress integrator
additional-hostnames option via relation, optional.

backend\_protocol

configure Nginx ingress integrator
backend-protocol option via relation, optional.

enable\_access\_log

configure Nginx ingress
nginx.ingress.kubernetes.io/enable-access-log option.

limit\_rps

configure Nginx ingress integrator limit-rps
option via relation, optional.

limit\_whitelist

configure Nginx ingress integrator
limit-whitelist option via relation, optional.

max\_body\_size

configure Nginx ingress integrator
max-body-size option via relation, optional.

owasp\_modsecurity\_crs

configure Nginx ingress integrator
owasp-modsecurity-crs option via relation, optional.

owasp\_modsecurity\_custom\_rules

configure Nginx ingress
integrator owasp-modsecurity-custom-rules option via
relation, optional.

path\_routes

configure Nginx ingress integrator path-routes
option via relation, optional.

retry\_errors

configure Nginx ingress integrator retry-errors
option via relation, optional.

rewrite\_target

configure Nginx ingress integrator
rewrite-target option via relation, optional.

rewrite\_enabled

configure Nginx ingress integrator
rewrite-enabled option via relation, optional.

service\_namespace

configure Nginx ingress integrator
service-namespace option via relation, optional.

session\_cookie\_max\_age

configure Nginx ingress integrator
session-cookie-max-age option via relation, optional.

tls\_secret\_name

configure Nginx ingress integrator
tls-secret-name option via relation, optional.

nginx\_route\_relation\_name

Specifies the relation name of
the relation handled by this requirer class. The relation
must have the nginx-route interface.

Returns

the NginxRouteRequirer.

Description

This function must be invoked in the charm class constructor.

#### def provide\_nginx\_route(     charm,     on\_nginx\_route\_available,     on\_nginx\_route\_broken,     nginx\_route\_relation\_name: str )

Set up nginx-route relation handlers on the provider side.

Arguments

charm

The charm that requires the nginx-route relation.

on\_nginx\_route\_available

Callback function for the nginx-route-available event.

on\_nginx\_route\_broken

Callback function for the nginx-route-broken event.

nginx\_route\_relation\_name

Specifies the relation name of the relation handled by this
provider class. The relation must have the nginx-route interface.

Description

This function must be invoked in the charm class constructor.
