我有一个在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应用程序
发布评论