本文介绍了访问socket.io服务器通过Apache网页服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这不会是一个非常愚蠢的问题碰到过,不过我正在学习如何实现socket.io服务器为我的网站产生的实时应用程序,但我的问题是,我想不通如何实现说在Apache应用服务环境。目前,当我运行节点server.js 开始我socket.io服务器,我必须通过访问来访问它的http://本地主机:XXXX ,其中 XXXX 是什么端口我把它连接到,自然。我不希望我的网站被强制这样的一个备用端口上查看,但我明明可以在服务器不重视80端口因为Apache上听。

I hope this doesn't come across as a terribly silly question, but I'm learning how to implement a socket.io server for my website to produce real-time applications, but my problem is that I can't figure out how to implement said applications in an Apache served environment. Currently, when I run node server.js to start my socket.io server, I have to access it by visiting http://localhost:XXXX where XXXX is whatever port I attach it to, naturally. I don't want my website to be forced to be viewed on an alternate port like this, but I obviously can't attach the server to port 80 since Apache is listening on that.

显然,一个自然的解决办法是停止Apache服务,然后节点上的80端口的方式,以避免碰撞的服务器,但我不想牺牲一切的阿帕奇提供的功能。基本上,我想继续通过Apache为我的网站的80端口,并通过socket.io 3000端口的实时应用程序的某些方面的整合,让我们说。

Obviously a natural solution would be to stop the Apache service and then node the server on port 80 that way to avoid a collision, but I don't want to sacrifice all of the functionality that Apache offers. Basically, I want to continue to serve my website via Apache on port 80, and integrate certain aspects of real-time applications via socket.io on port 3000, let's say.

有没有办法做到这一点,避免,我不想要的东西?让用户这些东西是1)访问我的网站:3000 中的URL,2)禁止了Apache,3)使用内部框架

Is there a way to do this that avoid the things I don't want? Those things being 1) having users access my site with :3000 in the URL, 2) disabling Apache, 3) using iframes.

先谢谢了。

推荐答案

一般来说,你应该能够隐藏的Node.js与mod_proxy的。进行搜索打开了这个有点:的 (旧链接死了,这是一个新的)

Generally, you should be able to hide Node.js with mod_proxy. A bit of searching turned up this: https://github.com/sindresorhus/guides/blob/master/run-node-server-alongside-apache.md (old link died, this is a new one)

不过,Socket.io可有点挑剔(),所以你可能与它的问题具体。

However, Socket.io can be a bit finicky (https://github.com/LearnBoost/socket.io/issues/25), so you may have problems with it specifically.

由于这票是有点老了,这是值得一试。只是,如果你有问题,不要感到惊讶。你以后被绑定的Node.js toport 80下一个赌注,并把它作为为Apache使用的(仍在开发中的公平位)。

As that ticket is a bit old, it's worth a shot. Just don't be surprised if you have problems. You're next bet after that is bind Node.js toport 80 and have it act as a reverse proxy for Apache with https://github.com/nodejitsu/node-http-proxy (still under a fair bit of development).

最佳的解决方案将它自己的服务器上运行它,只是你插座交通去socket.example.com或者类似的东西。

The optimal solution would be run it on it's own server and just have you're socket traffic go to socket.example.com or something like that.

这篇关于访问socket.io服务器通过Apache网页服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:51
查看更多