3 ms·
One of my favorite nginx features I just discovered is that you can use a regex in the server_name and then you can use the capture as a variable later [1] ...
by callmeed 13y ago
One of my favorite nginx features I just discovered is that you can use a regex in the server_name and then you can use the capture as a variable later [1] ... this lets you serve domains or subomains from completely different directories without a new conf file or a reload.
I'm using it at http://www.utterson.me http://www.utterson.me to serve up static Jekyll blogs on a subdomain.
I may be wrong, but I don't think Apache can do this (it can do regex but you don't get a variable).
[1] http://nginx.org/en/docs/http/server_names.html#regex_names http://nginx.org/en/docs/http/server_names.html#regex_names
- ericclemmons 13y agoI've done something similar in Apache with mod_vhostalias, where you set a VirtualDocumentRoot that specifies the pattern to match against and the dynamic directory path to serve up.