Welcome! Log In Create A New Profile

Advanced

Allow seperate fastcgi/php apps in both / as well as subdirectories

Posted by cezar 
Allow seperate fastcgi/php apps in both / as well as subdirectories
May 18, 2015 12:30PM
I thought this was a feature that NGINX could support, however from spending a couple days experimenting and stumping the folks in #nginx it appears that NGINX has some limitations that prevent this from working. For example, a nested PHP block for / is matched and executed rather than the nested PHP block for a subdirectory application. As location blocks don't allow for negate filters, there's no way to execute separate PHP blocks for separate apps; the / PHP block will override any subdirectory PHP blocks.

It's possible to run multiple apps in / as well as subdirectories as long as you can utilize one single PHP block for both. If, for example, you want to prepend a file in only one application, you run into issues. Furthermore, PHP environment variables are polluted with the variables from the / block, which causes issues in most frameworks.

If anyone can provide a working config for NGINX that allows for a PHP application in / and a totally separate application in /newsite/ that supports subdirectories such as /newsite/page1, /newsite/page2, etc. I'd love to see it, but from the several days of experimentation I've done, this is simply not possible in the current state of NGINX. I think this would be an extremely valuable feature to have and would appreciate it if you guys could add it to the todo list. Until then we'll be switching back to Apache.
Re: Allow seperate fastcgi/php apps in both / as well as subdirectories
May 18, 2015 02:22PM
UPDATE: I found a way to make this work, you need to set your try_files as $uri $uri/ @app and then create location @app { rewrite /app/(.*)$ /app/index.php?/$1 last; }

Very unintuitive, this took me approx 12 hours to resolve.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 127
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready