Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a virtual host configured in nginx that will do 'dynamic virtual hosting':

server {
    if ($host ~* www\.(.*)) {
        set $host_without_www $1;
        rewrite ^(.*)$ http://$host_without_www$1 permanent;
    }

    server_name_in_redirect off;

    listen xx.xx.xx.xx:80;

    server_name _;

    access_log /var/log/nginx/static_sites_access_log;
    error_log /var/log/nginx/static_sites_error_log;

    root /home/deployer/sites/$host;

    location ~ /\.ht {
        deny all;
    }
}

This works fine for static files. But now I want to host the occasional Sinatra app as well, so I want to use Passenger for that (I already have virtual hosts configured to use passenger with a bigger rails app).

I can add this:

if ( -d /home/deployer/sites/$host/public ) {
        set $passenger P;
    }
    if ( -f /home/deployer/sites/$host/config.ru ) {
        set $passenger "${passenger}C";
    }

to find out if $passenger = PC - e.g. there's public directory and config.ru exists. I can't, however, set passenger_enable or root inside an if.

Also, I don't want to put all static sites inside a public subdirectory.

The question is, how can I enable passenger and set root to the public subdirectory for projects that qualify?

I'm using passenger 3.2-experimental for this.

share|improve this question
    
It's all because if is evil. –  Dmitry Verkhoturov May 14 '12 at 13:29
    
@DmitryPaskal I know. Still, not sure how to set this up an other way. –  Ariejan May 15 '12 at 10:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.