Complete the code to define a server block that listens to all subdomains of example.com.
server {
server_name [1];
listen 80;
}The wildcard *.example.com matches all subdomains of example.com, like app.example.com or blog.example.com.
Complete the code to define a server block that matches any domain ending with .test.
server {
server_name ~[1];
listen 80;
}The regex \.test$ matches any domain ending with .test. The backslash escapes the dot, and $ means end of string.
Fix the error in the regex server_name to match domains starting with 'app' followed by any characters.
server {
server_name ~[1];
listen 80;
}The regex ^app.*$ matches any domain starting with 'app' followed by any characters. The caret ^ marks the start, and .* means any characters.
Fill both blanks to create a server block matching domains starting with 'dev' or 'test' followed by '.example.com'.
server {
server_name ~^([1]|[2])\.example\.com$;
listen 80;
}The regex ^(dev|test)\.example\.com$ matches domains starting with 'dev' or 'test' followed by '.example.com'.
Fill all three blanks to create a server block matching any subdomain of 'example.com' except 'www'.
server {
server_name ~^(?![1])[2]\.example\.[3]$;
listen 80;
}The regex uses a negative lookahead (?!www) to exclude 'www', then matches any subdomain with [a-z0-9-]+, and ends with '.example.com'.