Faye Server Requests Through Apache Web Server

838 views
Skip to first unread message

anil kumar

unread,
Mar 7, 2012, 5:25:37 AM3/7/12
to Faye users, anil....@efi.com
How to pass all the Faye Server Requests Through Apache Web Server.
And
Faye Transport can be WebSocket, I know Apache doesn't supports Web-
Sockets.
Actually I want hide the port (9292) from the outside world in the
following example, and I want to use WebSocket as a Faye Transport
medium.

require "faye"
faye_server = Faye::RackAdapter.new(:mount => "/faye", :timeout => 45)
faye_server.listen(9292)*
run faye_server*

James Coglan

unread,
Mar 7, 2012, 5:37:44 AM3/7/12
to faye-...@googlegroups.com
On 7 March 2012 10:25, anil kumar <anilku...@gmail.com> wrote:
How to pass all the Faye Server Requests Through Apache Web Server.
Actually I want hide the port (9292) from the outside world in the
following example, and I want to use WebSocket as a Faye Transport
medium.

require "faye"
faye_server = Faye::RackAdapter.new(:mount => "/faye", :timeout => 45)
faye_server.listen(9292)*
run faye_server*

If you want WebSocket to work, you can't use Apache. You could either run Faye on port 80 (the default HTTP port) or put HAProxy in front of it -- WebSocket should work even in HAProxy's http mode. 

anil kumar

unread,
Mar 7, 2012, 7:08:20 AM3/7/12
to faye-...@googlegroups.com
Thanks James,
Could you please refer any link that describes how to setup HAProxy as I am naive in this area.

Regards, Anil

James Coglan

unread,
Mar 7, 2012, 7:16:07 AM3/7/12
to faye-...@googlegroups.com
On 7 March 2012 12:08, anil kumar <anilku...@gmail.com> wrote:
Thanks James,
Could you please refer any link that describes how to setup HAProxy as I am naive in this area.

I don't know a lot about HAProxy, but I do test Faye through it. Here's a config I use to proxy to 3 backend servers (for testing distributed engines):


And here's the one I test faye-websocket with, to make sure sockets work through the proxy:


Installing HAProxy through apt-get or homebrew is easy. You run HAProxy by running `haproxy -f path/to/haproxy.conf` -- wrap an init.d/upstart/monit script around that to keep it running. 

radhames brito

unread,
Mar 7, 2012, 11:55:30 AM3/7/12
to Faye users
i Just set it up on apache with proxy pass incase you are interest i
can give you my configuration.

Note: is not using websocket, but is working.

anil kumar

unread,
Mar 7, 2012, 12:30:24 PM3/7/12
to faye-...@googlegroups.com

I have a my Rails App server and I want to run Faye push notification Server at 9292 port and I want to expose Faye server to outside world through apache with port 80. So that end users feel that there is only one server is running through apache.

E.g.

My Rails App URL: http://MyRailsApp/

Faye server URL: http://MyRailsApp/Faye

There are two ways to achieve the same:

1.       Run the Faye server at port 80, so no need to open the port 9292 in firewall.

2.       Use some proxy to expose http://MyFayeServer:9292/ as http://MyFayeServer.

But I want to use Apache as a proxy server for Faye server because it is already running on my machine to host rails App. I don’t want use another proxy server only for Faye server.

radhames brito

unread,
Mar 7, 2012, 4:09:42 PM3/7/12
to Faye users

> My Rails App URL:http://MyRailsApp/<http://myrailsapp/>
>
> Faye server URL:http://MyRailsApp/Faye<http://myrailsapp/Faye>

I have faye rinning with thin on port 9292 and reverproxied on apache
like this

ProxyPass /bayeux https://localhost:9292
ProxyPassReverse /bayeux https://localhost:9292

works great, all i do is subscribe like this

var client = new Faye.Client('http://MyRailsApp/bayeux/faye');

the end result is that faye is at http://MyRailsApp/bayeux, and
apachec will send all request to that uri to https://localhost:9292
which is my thin server




anil kumar

unread,
Mar 8, 2012, 12:29:19 AM3/8/12
to faye-...@googlegroups.com
Thanks Radhames,
 
Are you sure that you are getting server notification via web-socket calls (ws://FayeServerUrl) not via normal long polling call?
As I know Apache doesn't support Web-socket as off now.
I want to use web-socket if my browser supports it. :)

Ben Kimpel

unread,
Mar 8, 2012, 10:39:55 AM3/8/12
to Faye users
If he's doing a reverse proxy through apache i'm pretty sure that faye
is falling back to long polling.

On Mar 7, 11:29 pm, anil kumar <anilkumar8...@gmail.com> wrote:
> Thanks Radhames,
>
> Are you sure that you are getting server notification via web-socket calls
> (ws://FayeServerUrl) not via normal long polling call?
> As I know Apache doesn't support Web-socket as off now.
> I want to use web-socket if my browser supports it. :)
>
>
>
>
>
>
>
> On Thu, Mar 8, 2012 at 2:39 AM, radhames brito <rbri...@gmail.com> wrote:
>
> > > My Rails App URL:http://MyRailsApp/<http://myrailsapp/>
>
> > > Faye server URL:http://MyRailsApp/Faye<http://myrailsapp/Faye>
>
> > I have faye rinning with thin on port 9292 and reverproxied on apache
> > like this
>
> > ProxyPass /bayeuxhttps://localhost:9292
> > ProxyPassReverse /bayeuxhttps://localhost:9292
>
> > works great, all i do is subscribe like this
>
> >  var client = new Faye.Client('http://MyRailsApp/bayeux/faye');
>
> > the end result is that faye is athttp://MyRailsApp/bayeux, and
> > apachec will send all request to that uri tohttps://localhost:9292

James Coglan

unread,
Mar 8, 2012, 10:43:26 AM3/8/12
to faye-...@googlegroups.com
On 8 March 2012 05:29, anil kumar <anilku...@gmail.com> wrote:
Are you sure that you are getting server notification via web-socket calls (ws://FayeServerUrl) not via normal long polling call?
As I know Apache doesn't support Web-socket as off now.
I want to use web-socket if my browser supports it. :)

If you're putting Apache between your browser and the Faye server, you cannot use WebSocket. Faye will fall back to EventSource or long-polling.

anil kumar

unread,
Mar 9, 2012, 1:59:56 AM3/9/12
to faye-...@googlegroups.com
As you guys suggested that I tried to run my Faye server at port 80, Server runs successfully but Faye.js is not accessible from browser. Ports, other than port 80, are working fine.
Reply all
Reply to author
Forward
0 new messages