Is it possible to define a global constant variable in the nginx config file?
I would like to define a constant for an IP Address, as it's used in multiple location blocks - see below:
location / {
satisfy all;
allow 12.34.56.789;
deny all;
auth_basic "Restricted Remote";
auth_basic_user_file /etc/nginx/.htpasswd_gpu;
limit_req zone=login burst=5;
proxy_pass *************;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
Is there a way to define:
var my_ip_address = 12.34.56.789;
and then use that variable instead in the "allow" statement?
thanks!