Fix directory alias handling in Nginx - #84
Conversation
This PR addresses Nginx Directory aliases that were incorrectly used as filesystem paths in Nginx rewrite rules. This converts them to internal URL paths, prevents rewrite loops, and ensures regular redirects are processed before aliases. It also keeps alias listing and deletion working, including existing aliases. This fixes applications with a separate public directory, such as Roundcube 1.7. Tested on Debian 12 with different alias and redirect configurations.
|
Wow this looks really complex! Can you add some more details of exactly what kind of fixes it is doing, and when? |
Yeah, sure! It looks complex because Virtualmin must be able to create, find, and delete the same Nginx alias safely. So we care about the following:
And as you remember, Roundcube 1.7 exposed the problem because now its public files are inside a separate |
|
Ah so this fixes a case where an alias points to a sub-directory of the original directory? |
Yeah, that is one example, but the fix is more general. The alias API receives a filesystem path, while an Nginx rewrite needs a URL path. This change converts alias destinations under the website's document root into the correct internal URL. It handles both root and subdirectory aliases, and the other supported alias options. It also prevents the generated rewrite from matching itself again. |
Hi Jamie,
This PR fixes Nginx directory aliases that were incorrectly being used as filesystem paths in rewrite rules. It converts alias destinations to internal URL paths, prevents rewrite loops, and ensures regular redirects are processed before aliases.
It also keeps alias listing and deletion working, including existing aliases.
This fixes applications with a separate public directory, such as Roundcube 1.7.
Tested on Debian 12 with different alias and redirect configurations.