I have recently tried to install passenger on nginx. The installation works and everything is good. However I would like to run roundcube webmail on my server as well.

Basically my problem is that nginx has the root directive set to the passenger app:

root /home/me/www/hello/public

and roundcube is created as a symlink on the server as:


My question how do I get the url www.my-server.com to refer to the normal root but www.my-server.com/webmail to refer to the roundcube folder?

I have tried variations on the following in my nginx.conf with no luck:

location /webmail/ {
    #root /home/me/www;
    alias /home/me/www;
    try_files $uri /index.php;
    passenger_enabled off;

The above configuration results in 403 forbidden when using www.my-server.com/webmail and File not found when using the URI: www.my-server.com/webmail/index.php.

Any ideas?


That was a bit tricky but I found the solution in the nginx documentation about location.

As there is a location directive matching .php files this will take precedence over the /webmail/ location and since this does not declare a root location the global root will be used which still points to the passenger folder.

The solution was to add a root directive to the php matching location and limit php execution to the webmail path, like so:

index index.html index.htm index.php

location /webmail/ {
    root /home/me/www;

location ~ /webmail/.*\.php$ {
    root /home/me/www;

Now everything works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.