Variables
type
status
date
slug
summary
tags
category
icon
password
How to declare a variable
Variables in NGINX are similar to variables in other programming languages.
The
set
directive can be used to declare new variables anywhere within the configuration file:Variables can be of three types
- String
- Integer
- Boolean
Example 1.
Whenever
nginx.conf
is modified:- Run
sudo nginx -t
to ensure there are no errors.
- Run
sudo nginx -s reload
to reload the configuration.
Example 2.
The variables I demonstrated here are embedded in the ngx_http_core_module.
For a variable to be accessible in the configuration, NGINX has to be built with the module embedding the variable.
Reference Articles
Loading...
Last update: 2024-08-26