Is it possible to run two different Rails apps on the same domain (using a subdirectory)?
You can do this but its easier to use a subdomain like game.mydomain.com because then you can deal with this problem using nginx. For the seperation of the different ruby and rails versions use rvm (https://rvm.io/).
Then you can create a nginx config like this:
upstream mydomain.com { server unix:/var/run/thin/mydomain.0.sock; server unix:/var/run/thin/mydomain.1.sock; server unix:/var/run/thin/mydomain.2.sock; server unix:/var/run/thin/mydomain.3.sock;}upstream game.mydomain.com { server unix:/var/run/thin/game.mydomain.0.sock; server unix:/var/run/thin/game.mydomain.1.sock; server unix:/var/run/thin/game.mydomain.2.sock; server unix:/var/run/thin/game.mydomain.3.sock;}server { listen 80; server_name mydomain.com; access_log /path/to/rails/app/log/access.log; error_log /path/to/rails/app/log/error.log; root /path/to/rails/app/public; index index.html; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (!-f $request_filename) { proxy_pass http://mydomain.com; break; } }}server { listen 80; server_name game.mydomain.com; access_log /path/to/rails/app/log/access.log; error_log /path/to/rails/app/log/error.log; root /path/to/rails/app/public; index index.html; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (!-f $request_filename) { proxy_pass http://game.mydomain.com; break; } }}
That should do it for you if its acceptable to use subdomains instead of subfolders.
If you really wanna use subdirectories you can do this using nginx location
directive:
Yes
Run it on a Sub Domain you dont want to cause problems with your existing Application.