server_name in nginx does not match
I want to match with such FQDNs I came up with
server_name "~^(www.)?ucwebapi-uccore(\d{0,3})-(\d{0,3})\.testme\.net";
To Match
ucwebapi.testme.net
ucwebapi-uccore.testme.net
ucwebapi-uccore1-0.testme.net
ucwebapi-uccore999-999.testme.net
Validated with https://regex101.com/r/tAwEp9/2
Tested with
server_name "~^(www.)?ucwebapi-uccore(\d{0,3})-(\d{0,3})\.testme\.net ucwebapi1.testme.net";
to see if ucwebapi1.testme.de server is reachable at all.
Is there any restriction im not aware of? Thank you.
Try this:
server_name "~^(www.)?ucwebapi(-uccore)?(\d{1,3}-\d{1,3})?\.testme\.net";
It looks like there are some missing characters between your regex101 page and what ended up in your config.
I've also tuned it a bit so that it will NOT match:
ucwebapi-uccore999.testme.net
ucwebapi-uccore-.testme.net
ucwebapi-uccore-999.testme.net
I've never seen server_name configurations with double-quotes... but I'm not shure if that solves the problem.
Some example configurations here.
Edit: Do you have a default virtual server like this:
server {
listen 80;
server_name _;
return 404; # default
}
# now add your specific server
server {
listen 80;
server_name "~^(www.)?ucwebapi-uccore(\d{0,3})-(\d{0,3})\.testme\.net ucwebapi1.testme.net";
...
}
Specific configurations will only work if you have a default configured.
@abcdn: your absolutely right, i didn't know that!
Try:
server_name "~^(www.)?ucwebapi-uccore(\d{0,3})-(\d{0,3})\.testme\.net" ucwebapi1.testme.net;
Your server_name
quotes encompassed the entire line. What is probably perceived as 2 separate entries, nginx interpolated as a single entry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With