Can I use regexps or functions when creating variables? For example, I want to redirect some ports range (e.g., 7xxx -> 5xxx), but I would like do not create many servers - just one like this:
server {
listen 127.0.0.1:7000-7200;
listen 7000-7200;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
location / {
set $port 5${server_port:2};
# or any substring function:
set $port 5${substring($server_port,2)};
proxy_pass http://0.0.0.0:$port/;
}
}
i.e. $port is equal $server_port replacing the first character to symbol '5'. Can I do this?
Thank you for advance/