Discourse Docker + Other Rails App on the same droplet

AI-generated summary

The discussion revolves around running a second Rails app alongside a Discourse installation on the same Digital Ocean droplet using Docker. chrisalley wants to set up the sites with the following domains: http://www.mysite.com and http://mysite.com for the other Rails app, and http://forums.mysite.com for the Discourse Docker app.

featheredtoast suggests using multiple server {} blocks in nginx to achieve this, providing an example configuration. sam recommends using haproxy for this purpose, but featheredtoast notes that nginx can also be used.

chrisalley asks how the local Rails app port number is configured using nginx and passenger, specifically regarding the proxy_pass directive.

I already have a Discourse installation set up on Digital Ocean with Docker using the beginner guide. I wish to put a second Rails app on the same droplet. I see that there’s a similar discussion in this topic and this other topic but no specific solution described in detail.

The sites need to be set up like this:

Other Rails App: http://www.mysite.com and http://mysite.com
Discourse Docker: http://forums.mysite.com

Alternatively a seperate droplet could be used for the other Rails app, but if possible I would like to configure nginx to have them on the same droplet. I’m just not sure how to configure nginx to point to both the Docker Discourse app and a regular Rails app. Any pointers would be appreciated. This seems like it would be a common configuration worth documenting here.

In general you would use haproxy for this kind of work.

You run haproxy on the bare metal and then have it split out requests to the various domains you are hosting.

It is also doable with nignx as well, using multiple server {} blocks, and matching the proxy by server_name.

something like:

server {
  listen 80;
  server_name www.mysite.com;
  location / {
    proxy_pass http://localhost:4567/; #your rails app port
  }
}
server {
  listen 80;
  server_name forums.mysite.com;
  location / {
    proxy_pass http://localhost:8080/; #your discourse port as seen by the host
  }
}

How is the local Rails app port number configured (using nginx and passenger)?