1

say I have a wordpress site:

https://www.foobar.com

and I want to have an entry point to a rails app at a certain subdirectory within that same domain:

https://www.foobar.com/rails_app

I know this is possible if both the wordpress app and the rails app are hosted on the same box, but is this in anyway possible if they are hosted on different boxes?

I do not want to use subdomains because I am trying to allow ajax post requests from one to the other and not having to deal with single origin policy stuff.

patrick
  • 153
  • 2
  • 8

4 Answers4

1

Not exactly, but close.

The host with the rails app needs to have its own distinct hostname. But you can create a Revere Proxy from the primary domain to the rails app.

Add the following to your Apache virtual host for www.foobar.com:

ProxyPass           /rails_app    https://railsapp_server.foobar.com:3000/rails_app
ProxyPassReverse    /rails_app    https://railsapp_server.foobar.com:3000/rails_app

Obviously you'll need to make sure the URL on the right is correct for your application.

bahamat
  • 6,263
  • 24
  • 28
  • will this approach still get around the single origin policy so that I can do XHR posts from the rails app to wordpress? – patrick Oct 03 '12 at 21:36
0

Not that I am aware - you'd need to point the A records for both pages to the same server. Sub-domains work because it's a different set of A records that can be pointed to another IP address in your DNS manager.

DKNUCKLES
  • 4,028
  • 9
  • 47
  • 60
0

You'll need to reverse proxy from one host to the other host -- any modern web server can handle this with ease. If you're doing this with shared hosting, your web host may not be especially amenable to that.

On the other hand, you can also just run WordPress and your Rails app on the same host.

jgoldschrafe
  • 4,395
  • 18
  • 18
0

I find the simplest way to achieve the desired results is to write an agent on the web host that passes the information between servers. i.e.

  • The web server makes an AJAX request to the agent
  • The agent sends the request verbatim to the app server and waits for a response
  • The app server replies to the agent
  • The agent forwards the reply the web server

Only the traffic between the web server and agent is AJAX. The traffic between the agent and app server is just regular network traffic.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109