Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

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.

share|improve this answer
    
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 3 '12 at 21:36

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.