Discourse Docker + Other Rails App on the same droplet

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.

1 Like

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.

1 Like

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)?