Skip to content

Latest commit

 

History

History
54 lines (46 loc) · 2.01 KB

custom-template.md

File metadata and controls

54 lines (46 loc) · 2.01 KB

Custom NGINX template

The NGINX template is located in the file /etc/nginx/template/nginx.tmpl.

Using a Volume it is possible to use a custom template. This includes using a Configmap as source of the template

        volumeMounts:
          - mountPath: /etc/nginx/template
            name: nginx-template-volume
            readOnly: true
      volumes:
        - name: nginx-template-volume
          configMap:
            name: nginx-template
            items:
            - key: nginx.tmpl
              path: nginx.tmpl

Please note the template is tied to the Go code. Do not change names in the variable $cfg.

For more information about the template syntax please check the Go template package. In addition to the built-in functions provided by the Go package the following functions are also available:

  • empty: returns true if the specified parameter (string) is empty
  • contains: strings.Contains
  • hasPrefix: strings.HasPrefix
  • hasSuffix: strings.HasSuffix
  • toUpper: strings.ToUpper
  • toLower: strings.ToLower
  • buildLocation: helps to build the NGINX Location section in each server
  • buildProxyPass: builds the reverse proxy configuration
  • buildRateLimit: helps to build a limit zone inside a location if contains a rate limit annotation

TODO:

  • buildAuthLocation:
  • buildAuthResponseHeaders:
  • buildResolvers:
  • buildLogFormatUpstream:
  • buildDenyVariable:
  • buildUpstreamName:
  • buildForwardedFor:
  • buildAuthSignURL:
  • buildNextUpstream:
  • filterRateLimits:
  • formatIP:
  • getenv:
  • getIngressInformation:
  • serverConfig:
  • isLocationAllowed:
  • isValidClientBodyBufferSize: