将我的域指向我的node.js实例 [英] Pointing my domain to my node.js instance
问题描述
谢谢
好的,我从来没有尝试过,但是可以在.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屋!