My problem is: I'm trying to configure a nginx with multiple cakephp applications (that will be added and removed from time to time). And I want to this configuration to be dynamic (if the subdirectory exists, then it will be loaded as a cakephp application, if not, 404).
But the thing is: I cannot configure the nginx to serve correctly the root for each application (i do not want to put every location on my conf file).
Ex:
/var/www/cakephp1 + /app/webroot/ Will be served as: www.mydomain.com/cakephp1
/var/www/cakephp2 + /app/webroot/ Will be served as: www.mydomain.com/cakephp2
I know how to make a configuration to run a single app. Any ideas how to achieve this? With dynamic configuration?
You can use try_files
for this easily. If you match anything in your location
directive, you can reuse any part of the matching group in your try_files
directives to try multiple locations. Also, you can use things such as $http_host
to compose a different app root.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.