我有一个服务器部分,看起来像:
server {
listen 80;
server_name arch;
root /data/apps/production/fentonGem2/current/public;
passenger_enabled on;
}
哪个工作正常.但是,我想将两个或更多应用程序部署到同一个server_name和listen端口.所以我可能会使用以下内容:
server {
listen 80;
server_name arch;
location /app1 {
root /data/apps/production/fentonGem2/current/public;
passenger_enabled on;
}
location /app2 {
root /data/apps/production/fentonGem3/current/public;
passenger_enabled on
}
}
但这不起作用.有谁知道如何部署两个单独的应用程序,并通过以下方式与他们联系:
http://domain.com/app1/
和:
http://domain.com/app2/
该设置使用Nginx,Phusion Passenger,Rack和Sinatra.
更新:
感谢您的回复,但我发现它们并且方法没有用,尽管我可能不太了解它.看起来我必须在另一个应用程序中部署一个应用程序,这看起来非常不干净.我最终使用的是具有单独的服务器部分,然后更新我的/ etc / hosts文件以获得相同IP地址的服务器别名.所以现在我有:
http://app1/
和:
http://app2/
和服务器部分看起来像:
server {
listen 80;
server_name app1;
root /data/apps/production/app1/current/public;
passenger_enabled on;
}
server {
listen 80;
server_name app2;
root /data/apps/production/app2/current/public;
passenger_enabled on;
}
在/ etc / hosts中:
192.168.1.30 app1 app2
解决方法:
以下工作:
>首先创建了名为app1和app2的符号链接,指向“public”目录,如下所示:
ln -s /data/apps/production/fentonGem2/current/public /data/apps/production/fentonGem2/current/app1
ln -s /data/apps/production/fentonGem2/current/public /data/apps/production/fentonGem2/current/app2
>修改nginx.conf以使用rails_base_uri,它应类似于以下内容:
...
server {
listen 80;
server_name arch;
location ^~ /app1 {
root /data/apps/production/fentonGem2/current;
rails_env production;
passenger_enabled on;
passenger_base_uri /app1;
}
location ^~ /app2 {
root /data/apps/production/fentonGem2/current;
rails_env production;
passenger_enabled on;
passenger_base_uri /app2;
}
}
...
希望这可以帮助.