justin
1
I am using a regular expression with a capture group in my server_name
directive. It looks like:
server_name (?<account>.+)\.mydomain\.com$
The problem is that I want to expand it slightly and say anything except
web3.mydomain.com. I.E.
something.mydomain.com matches, but web3.mydomain.com does not match.
How is this possible?
Posted at Nginx Forum:
justin
2
On Sun, Mar 03, 2013 at 12:43:57PM -0500, justin wrote:
Hi there,
I am using a regular expression with a capture group in my server_name
directive. It looks like:
server_name (?<account>.+)\.mydomain\.com$
Module ngx_http_core_module for details of how the matching server{}
block is chosen.
The problem is that I want to expand it slightly and say anything except
web3.mydomain.com. I.E.
something.mydomain.com matches, but web3.mydomain.com does not match.
How is this possible?
Make a different server{} block that matches web3.mydomain.com.
f
Francis D. [email protected]
justin
3
I actually have a working regular expression which should work now:
server_name ^(?!web3.)(?.+).mydomain.com$;
But for some odd reason when I restart nginx, I am getting:
nginx: [emerg] unknown “account” variable
This should work though, right?
Posted at Nginx Forum:
justin
4
On Sun, Mar 03, 2013 at 02:21:10PM -0500, justin wrote:
Hi there,
I actually have a working regular expression which should work now:
server_name ^(?!web3.)(?.+).mydomain.com$;
http://nginx.org/r/server_name
Pay particular attention to the line that begins “It is also possible
to use regular expressions in server names”.
But for some odd reason when I restart nginx, I am getting:
nginx: [emerg] unknown “account” variable
Did you get that message when you tested with your initial version too?
f
Francis D. [email protected]
justin
5
No, simply doing
server_name ~^(?.+).mydomain.com$;
Works. This may be a bug with nginx? The new regular expression is valid
and
should work.
Posted at Nginx Forum:
justin
6
On Sun, Mar 03, 2013 at 03:16:09PM -0500, justin wrote:
Hi there,
server_name ~^(?.+).mydomain.com$;
Works.
Correct.
Now compare that line with the server_name lines in the previous mails.
This may be a bug with nginx?
No.
The new regular expression is valid and should work.
Yes; nginx is happy with the regular expression, provided that it knows
that it is intended to be a regular expression.
f
Francis D. [email protected]
justin
7
My bad, stupid mistake, forgot the ^.
Working fine now. Thanks.
Posted at Nginx Forum: