passenger:如果找不到文件,则将请求传递给机架应用程序

时间:2013-10-23 21:06:47

标签: ruby nginx passenger rack

如果它是php,那就是这样的:

server {
    server_name   ...;
    root   /path/to/root/1;
    location / {
        try_files   $uri   @root2;
    }
    location @root2 {
        root   /path/to/root/1;
        try_files   $uri   /index.php?$args;
    }
    location = /index.php {
        include   fastcgi_params;
        fastcgi_pass   php;
    }
}

换句话说,重点是将公共文件分成几个目录。有没有办法用passenger + nginx + sinatra(准确地说)来做到这一点?

UPD 基本nginx / passenger设置:

server {
    server_name example.com;
    root   /home/yuri/example.com/public;
    passenger_enabled   on;
}

有关详细信息,请参阅documentation

1 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情:

server {

  [...]

  root /path/to/public/folder;

  [...]

  location / {
    # Serve static files or forward to passenger
    try_files $uri $uri.html @passenger
  }

  location @passenger {
    passenger_enabled on;
    ...
  }
}