简体   繁体   English

如何在我的骨干网应用程序中使用node.js和套接字

[英]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 我的node.js服务器安装在

/usr/local/bin/node 在/ usr / local / bin目录/节点

I have an index.html and server.js files located at 我有一个index.html和server.js文件位于

/usr/local/bin 在/ 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. 我已经安装了一个在localhost:8888上运行的聊天应用程序,主应用程序/网站在localhost:8000上运行。 My backbone files and main site is located on my apache server, for arguments sake say /usr/local/apache/html 我的主干文件和主站点位于我的apache服务器上,出于参数考虑,请说/ 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 . 您需要使用mod_proxy将Apache设置为反向代理。 This will allow you to redirect requests from one port to another, making your Backbone client application only see one server. 这将使您能够将请求从一个端口重定向到另一个端口,从而使Backbone客户端应用程序只能看到一个服务器。

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: 因此,例如,如果您想在www.mysite.com/chat上使用聊天客户端,则需要首先安装mod_proxy ,然后按如下所示设置站点的conf文件:

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 您可以在此处阅读有关mod_proxy更多信息: http : //httpd.apache.org/docs/2.2/mod/mod_proxy.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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