Answer the question
In order to leave comments, you need to log in
How to make take variable from hostname and substitute it as proxy port?
Greetings! The bottom line is that there are several boxed builds on gitlab, for each deployment goes to its own host.
For example box100.example.net, box101.example.net ..... box109.example.net
Hosts
are described as regular expression box10[0-9]{1}\.example\.net
on lnmp.
I need to somehow extract a number from the hostname, make it a variable $box_port and substitute it in proxy_pass.
for example proxy_pass http://10.15.31.11:${box_port}80;
Answer the question
In order to leave comments, you need to log in
I got it like this:
server_name "~^box(?<box_port>[\d]{3})\example\.ru$" ;
proxy_pass http://$proxy_app:${box_port}80;
sed? expressions for extracting part of a string are highly dependent on the input data - what is correct for one case often needs to be rewritten for another
, it usually looks like
(this is just an example)
x=$(blah | sed -n "s/.*\(${SELENIUM_VERSION}\ /selenium-server-standalone[^<][^>]*\)<\/Key>.*/\1/p")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question