我们需要请求主机的域部分。
Fe:如果www1.domX.here是请求的主机,我们需要domX.here变量。
不工作:
map $http_host $this_dom {
default $http_host;
~^www1\.(?<this_dom>)$ $this_dom;
}
server {
server_name
www1.dom1.here
www1.dom2.here
www1.dom3.here
www1.dom4.here
www1.dom5.here;
location /somestuff {
# local content delivery
root /shared/somestuff;
}
location / {
return 301 https://www.$this_dom$request_uri;
}
}
此示例导致一个空域。
目前以这种方式解决了它:
if ($host ~* ^www1\.(.*)$) {
set $this_dom $1;
}