How to configure nginx for websockets using Integrated Passenger (not standalone)

163 views
Skip to first unread message

James Whitmarsh

unread,
Dec 13, 2016, 11:56:15 AM12/13/16
to Phusion Passenger Discussions
There are a lot of answers in the group (and after a thorough google search) about getting websockets running in standalone mode, using proxy passing, but how do we do it with integrated mode? 

This is my nginx config:

   server {
        listen      
80;
        server_name servername
.com

       
# static files
        root
/var/www/product/demo/current/dist;
        index index
.html;


        location
/ {
            try_files $uri $uri
/ /index.html =404;
       
}

       
# express api
        location
/api {
            root
/var/www/product/demo/current;
            passenger_enabled on
;
            passenger_app_type node
;
            passenger_app_root
/var/www/product/demo/current;
            passenger_startup_file dist
/index.js;
            passenger_app_env demo
;

            passenger_sticky_sessions on
;
       
}
   
}

As you can see, we're hosting the static files with just nginx, and then using Passenger on our /api location. 

Please let me know if you need any more info!

Thanks,

James

Daniel Knoppel

unread,
Dec 14, 2016, 5:32:59 AM12/14/16
to Phusion Passenger Discussions

James Whitmarsh

unread,
Dec 15, 2016, 4:44:15 AM12/15/16
to Phusion Passenger Discussions
Thanks for the reply Daniel, but that documentation is for Ruby apps, this is a node app - as far as I can tell that documentation doesn't apply. 

All the nginx documentation (and some of your own) suggests using proxy_pass to get websockets working, but since I don't know what port the app is running on (because of integrated passenger) I can't use that. Am I missing something here? 

Hongli Lai

unread,
Dec 15, 2016, 4:50:55 AM12/15/16
to phusion-passenger
When using the Nginx integration mode you don't have to do anything.
Websockets work out of the box there.

The 'passenger_enabled on' directive is equivalent to what
'proxy_pass' would have done in a reverse proxy setting:
'passenger_enabled on' sets up an internal reverse proxy connection
and automatically configures that with WebSocket support.
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/48465d79-6cce-4f77-83f4-1ef17367df3f%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Phusion B.V. | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 63501007 (The Netherlands)
Reply all
Reply to author
Forward
0 new messages