Skip to content

Allows defining global key-value labels in Nginx configuration. These labels can be used in variables for request processing, logging, or dynamic configuration.

License

Notifications You must be signed in to change notification settings

HanadaLee/ngx_http_label_module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ngx_http_label_module

Name

ngx_http_label_module allows defining global key-value labels in Nginx configuration. These labels can be used in variables for request processing, logging, or dynamic configuration.

Table of Content

Status

This Nginx module is currently considered experimental. Issues and PRs are welcome if you encounter any problems.

Synopsis

http {
    label environment production;
    label cluster_id my_cluster_id;
    label server_region us-east-1;
    label server_id my_server_id;
    label ...

    server {
        listen 80;
        server_name example.com;
        location / {
            add_header Server-Id $label_server_id;
            add_header Cluster-Id $label_cluster_id;
            add_header All-Labels $labels;
            return 204;
        }
    }
}

Installation

To use theses modules, configure your nginx branch with --add-module=/path/to/ngx_http_label_module.

Directives

label

Syntax: label key value;

Default: none

Context: http

Defines a global key-value label that can be accessed via variables. The label key is only allowed to be letters, numbers, and _. The same key cannot be defined repeatedly. The label value does not allow the use of & and =.

Example:

label environment production;
label region us-east-1;

labels_hash_max_size

Syntax: labels_hash_max_size number;

Default: labels_hash_max_size 512;

Context: http

Sets the maximum size of the hash table for storing labels.

labels_hash_bucket_size

Syntax: labels_hash_bucket_size number;

Default: labels_hash_bucket_size 32|64|128;

Context: http

Sets the bucket size of the hash table for labels. Default value depends on the processor’s cache line size. The details of setting up hash tables are provided in a separate document.

Variables

$label_name

Accesses the value of a specific label by its key.

$labels

Returns all defined labels in the format key1=value1&key2=value2, like $args. All label keys will be printed in lowercase letters.

Author

Hanada [email protected]

License

This Nginx module is licensed under BSD 2-Clause License.

About

Allows defining global key-value labels in Nginx configuration. These labels can be used in variables for request processing, logging, or dynamic configuration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages