使用Capistrano + nginx在单个数字海洋飞沫中部署多个Rails应用程序

编程入门 行业动态 更新时间:2024-10-16 02:24:09
本文介绍了使用Capistrano + nginx在单个数字海洋飞沫中部署多个Rails应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在IP xxx.xxx.xxx.xx的数字海洋服务器上运行的Rails应用程序,现在很容易轻松地与Capistrano一起部署,现在我正在考虑使用capistrano将另一个应用程序部署到同一服务器上,经过大量研究后,我仍未获得任何适当的解决方案以解决我的疑问,或者找不到任何最佳的教程。

在部署该解决方案之前需要注意哪些基本步骤

第二个应用程序应该监听哪个nginx端口,默认为80,第一个应用程序已经在监听该端口。 b $ b

如何将第二个应用程序部署到同一个Droplet之后,现在可以使用ip访问第一个应用程序??

解决方案

对于每个应用,您需要确保所使用的服务器正在不同的套接字上监听。

您必须在Nginx配置中添加另一个服务器块,例如低,

上游app_one {#server1 SOCK文件的路径} 上游app_two {#server2的SOCK文件的路径} 服务器{监听80; server_name IP; #先前定义的应用程序根目录 root / root / app_one / public; try_files $ uri / index.html $ uri @app; 位置@app { proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_set_header主机$ http_host; proxy_redirect关闭; proxy_pass http:// app_one; } error_page 500502503504 / 500.html; client_max_body_size 4G; keepalive_timeout 10; } 服务器{听8080; server_name IP; #先前定义的应用程序根目录 root / root / app_two / public; try_files $ uri / index.html $ uri @app; 位置@app { proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_set_header主机$ http_host; proxy_redirect关闭; proxy_pass http:// app_two; } error_page 500502503504 / 500.html; client_max_body_size 4G; keepalive_timeout 10; }

I have a rails application running on a digital ocean server with IP xxx.xxx.xxx.xx .the deployed with Capistrano was easy now running with ease.Now I'm thinking to deploy another application to the same server using capistrano, After many research i'm not getting any proper solutions for my doubts or cant find any best tutorials for this.

What are the essential steps to look after before deploying the second application to the server?

Which nginx port the second application should listen to, 80 is default and the first application is already listening to that.?

How to access the second application after if deployed to the same droplet, now i can access the first application using the ip.?

解决方案

For each app, you need to make sure whatever server you are using is listening on a different socket.

After that, you have to add another server block in Nginx configurations like below,

upstream app_one { # Path to server1 SOCK file } upstream app_two { # Path to server2 SOCK file } server { listen 80; server_name IP; # Application root, as defined previously root /root/app_one/public; try_files $uri/index.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass app_one; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } server { listen 8080; server_name IP; # Application root, as defined previously root /root/app_two/public; try_files $uri/index.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass app_two; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; }

更多推荐

使用Capistrano + nginx在单个数字海洋飞沫中部署多个Rails应用程序

本文发布于:2023-10-28 04:08:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535475.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   应用程序   海洋   数字   飞沫

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!