Deploying two dancer apps in same virtual host on apache
Hi folks. I have two dancer apps (a front end UI, and a backend REST server) that i want to have deployed as separate dancer apps. I'd like to do this using apache. i can do it in any way under apache (i have the freedom to configure things most anyway i need). I've successfully deployed two apps using two different virtual hosts, however in this case, the frontend app sends pages back to the browser that contain AJAX requests that want to talk directly to the backend app. I can't do this via two different virtual hosts due to same-origin-policy, so i need to deploy both apps under the same virtual host. Any ideas on how to do this? I've been messing with the config files for a couple of hours, but to no avail. I checked on "the google", and on the dancer website, but the deployment guide only talks about multiple sites on the same host using Plack::Builder and starman, and to be honest, i don't really understand PSGI and Plack. Thanks a bunch. ...alex... PS, the latest version of my apache virtual host config can be found at http://paste.perldancer.org/2298W43paS2hg. It kind of works, but i think it only works because depending on how the apache worker was initialized, it's using one or the other dancer app.
On Sep 4, 2011, at 11:50 AM, Alex Tang wrote:
I've successfully deployed two apps using two different virtual hosts, however in this case, the frontend app sends pages back to the browser that contain AJAX requests that want to talk directly to the backend app. I can't do this via two different virtual hosts due to same-origin-policy, so i need to deploy both apps under the same virtual host
Consider using JSONP. That way you can have two separate virtual hosts communicating with Ajax, no problem. This will also give you the flexibility to move one or the other app to a different web server if and when the need arises. JSONP was invented for this very reason, to get around the same origin policy.
Hi, On Sun, Sep 4, 2011 at 5:50 PM, Alex Tang <altitude@funkware.com> wrote:
I have two dancer apps (a front end UI, and a backend REST server) that i want to have deployed as separate dancer apps. I'd like to do this using apache. i can do it in any way under apache (i have the freedom to configure things most anyway i need).
If the JSONP recommendation from Mr. Puneet Kishor is not an option, consider this alternative: * start both apps independently using one of the PSGI-compatible servers. I recommend Starman or Twiggy if you are on a UNIX system; * configure you Apache as a reverse proxy, map the main UI app as / and the REST API as /api. That should solve your problem nicely. I use this all the time, although I use nginx and not Apache. Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ http://about.me/melo xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Thanks. I'm going to use JSONP (you learn something new every day...can you tell i'm not a frontend developer by trade? :) ), but also two servers as you recommend. I've been crawling through the archives and the source trying to figure out how to get two apps running in apache or even two apps in a single star man instance to run properly. Neither seemed to work well for me. I finally found these messages: http://www.backup-manager.org/pipermail/dancer-users/2011-July/001617.html and http://www.backup-manager.org/pipermail/dancer-users/2011-July/001618.html which seem to say that it's not a good idea to try what i was doing. i've gone back to separate starman servers and proxying from apache. Thanks! ...alex... On Sep 5, 2011, at 2:37 AM, Pedro Melo wrote:
Hi,
On Sun, Sep 4, 2011 at 5:50 PM, Alex Tang <altitude@funkware.com> wrote:
I have two dancer apps (a front end UI, and a backend REST server) that i want to have deployed as separate dancer apps. I'd like to do this using apache. i can do it in any way under apache (i have the freedom to configure things most anyway i need).
If the JSONP recommendation from Mr. Puneet Kishor is not an option, consider this alternative:
* start both apps independently using one of the PSGI-compatible servers. I recommend Starman or Twiggy if you are on a UNIX system; * configure you Apache as a reverse proxy, map the main UI app as / and the REST API as /api.
That should solve your problem nicely. I use this all the time, although I use nginx and not Apache.
Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ http://about.me/melo xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
participants (3)
-
Alex Tang -
Mr. Puneet Kishor -
Pedro Melo