I have directory containing FastCGI projects, to be more specific different versions of the same project. For example, there are ver1
and ver2
directories located at /some/dir/project/
and I want them to be ver1.project.example.com
and ver2.project.example.com
respectively.
How should I do it with nginx wi开发者_如何学Gothout creating different configs for each version and assuming that new versions may be added dynamically?
in /etc/nginx/sites-enabled/project
:
server {
server_name ~^(?<version>\w+)\.project\.example\.com;
root /some/dir/project/$version;
include fastcgi_params;
}
adding a new version directory at /some/dir/project/version99
will automatically make it available at version99.project.example.com
.
Regarding the multiple config issue., it can be solved using an nginx inclusion file include fastcgi_params;
. I don't know about variable server and socket locations, however, you should probably use multiple clauses for that. To make things quicker you could write something like add-fcgi-subdomain.sh
. I resolved this issue once using templates for nginx configs and shell scripts to generate them from /var/www.
精彩评论