Previous version was fully functionnal. One of the problems concerns optimisations:
Too much tests to check files or directories
Regex not enough generic
As a consequence, NGinx shall behave poorly under eavy load. More, when adding a new vhost, you had to copy the whole rewrite rules set and adapt it.
Try to fix this design issues.
Previous configuration summary
Here is what we got:
Fixes to apply
Generic Regex
We have to delete domainname usage into regex so that we don't need to adapt rules for each vhosts.
As an example: if ($host ~* ^domain\.tld$) { will be if ($host ~* ^[.*]+\.[.*]+$) {.
Files and directories checks
Most of the tests are in fact not relevant.
Files and directories checks
The only 2 tests we have to keep are related to SSL and authentication support. All the other ones can and should be deleted.
Rewrite from www.domain.tld/subdir into subdir.domain.tld
Here again, we got a perfs killer. Rules are optimized, but you just have to take care about your link policy to make them optional. They were here just to avoid duplicate content.
Final configuration from domain.tld
Conclusion
Once more, this way of doing things is not perfect.
But it allows to prepare next step: adding PHP-FPM support. More to come !
I spend most of my free time on the Internet working on GNU/Linux with Debian or CentOS, virtualization with Xen and KVM technology, as well as cluster stacks with corosync and OpenAIS. Particularly interested in Linux, Netfilter, virtualization, monitoring and clusters, most of my personal works are published on this website and others should not delay. By way professional, I manage servers running RedHat or CentOS and VMware ESXi farm. From time to time, I manage to drop my keyboard and read a book while listening to music, but it never lasts long.
e-mail : jean point baptiste point favre arobase gmail.com