見せます。
構成ファイル
server {
server_name example.com www.example.com;
root www/pub;
}
server {
server_name ~^(.*)\.example\.com$ ;
root www/pub/$1;
}
テストファイル
2つのテストファイルがあります。
$ cat www/pub/index.html
COMMON
$ cat www/pub/t/index.html
T
テスト中
静的サーバー名:
$ curl -i -H 'Host: example.com' http://localhost/
HTTP/1.1 200 OK
Server: nginx/0.8.54
Date: Wed, 23 Mar 2011 08:00:42 GMT
Content-Type: text/html
Content-Length: 7
Last-Modified: Wed, 23 Mar 2011 07:56:24 GMT
Connection: keep-alive
Accept-Ranges: bytes
COMMON
$ curl -i -H 'Host: www.example.com' http://localhost/
HTTP/1.1 200 OK
Server: nginx/0.8.54
Date: Wed, 23 Mar 2011 08:00:48 GMT
Content-Type: text/html
Content-Length: 7
Last-Modified: Wed, 23 Mar 2011 07:56:24 GMT
Connection: keep-alive
Accept-Ranges: bytes
COMMON
正規表現サーバー名:
$ curl -i -H 'Host: t.example.com' http://localhost/
HTTP/1.1 200 OK
Server: nginx/0.8.54
Date: Wed, 23 Mar 2011 08:00:54 GMT
Content-Type: text/html
Content-Length: 2
Last-Modified: Wed, 23 Mar 2011 07:56:40 GMT
Connection: keep-alive
Accept-Ranges: bytes
T
subdomain 1
/x.example.com
-明確にできますか?