将我的域指向我的node.js实例 [英] Pointing my domain to my node.js instance

查看:134
本文介绍了将我的域指向我的node.js实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有运行whm / cpanel的服务器,最近我一直在尝试使用node.js。我有一个小节点测试服务器运行,我想指向一个域。到目前为止,我一直在使用whm来创建帐户并处理域名,但这是一个不同的场景,当有多个其他域指向其他域名时,我几乎不知道如何使域名指向服务器上的某个域



谢谢

解决方案

好的,我从来没有尝试过,但是可以在.htaccess文件中使用重写规则,并将所有内容重写到端口8000,在那里您的node.js服务器正在运行。



首先,设置你的node.js服务器来监听端口8000。



然后,在cpanel和doc根目录中创建一个正常的域添加一个.htaccess文件与此重写:

  RewriteRule ^\ http:\ / \ / 127.0.0.1 \\ \\:%(8000)REQUEST_URI[P,QSA,L] 

到端口8000,其中node.js将关注的。但是我不知道持久连接/ websockets是否会与此策略配合使用。在这种情况下可能会直接跳到服务器上的端口8000来跳过apache。



资料来源: http://es.w3support.net/index.php?db=sf&id=59994


I own a server running whm / cpanel, and I have recently been experimenting with node.js. I have a little node test server running and i would like to point a domain at it. Up till now, I have been using whm to create accounts and deal with domains, but this is a different scenario, and I have little knowledge about how to make a domain point to something on my server when there are multiple other domains pointing to other different things on my server at the same time.

Thanks

解决方案

Ok, I have never tried this, but you could use a rewrite rule in a .htaccess file and rewrite everything to goto to port 8000 where you have your node.js server running.

So first, set up your node.js server to listen to port 8000.

Then, create your domain like normal in cpanel, and in the doc root add a .htaccess file with this rewrite:

RewriteRule ^ "\ http: \ / \ / 127.0.0.1 \:% (8000) REQUEST_URI" [P, QSA, L]

That should just forward everything internally to port 8000 where node.js will take care of it. But I don't know how persistent connections / websockets will work with this strategy. It may be better to skip apache in those cases by going directly to the port 8000 on your server.

Source: http://es.w3support.net/index.php?db=sf&id=59994

这篇关于将我的域指向我的node.js实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆