简体   繁体   中英

How to use node.js and sockets within my backbone application

This should be a fairly simple question to answer I think.

my node.js server is installed at

/usr/local/bin/node

I have an index.html and server.js files located at

/usr/local/bin

When I run node it works fine. I have installed a chat application which runs at localhost:8888 the main application/website runs at localhost:8000. My backbone files and main site is located on my apache server, for arguments sake say /usr/local/apache/html

How can I move my chat application into the main site so that I can access the chat app through node?

I've currently got two parts of the site working on different ports and I need to integrate the chat part.

Any advice on this would be great.

Thanks in advance :)

You need to setup Apache as a reverse proxy using mod_proxy . This will allow you to redirect requests from one port to another, making your Backbone client application only see one server.

So for instance, if you want your chat client available at www.mysite.com/chat, you would need to first install mod_proxy and then setup your site's conf file as such:

ServerName www.mysite.com

ProxyRequests off

<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>

<Location /chat>
        ProxyPassReverse http://localhost:8888/
</Location>

You can read more about mod_proxy here: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM