dsgdg54ef4365
2014-01-17 09:40
浏览 263

设置laravel来处理端口号?

I am working with nodejs, expressjs, and socket.io I am triggering events on my web app with a mobile phone over the nodejs server.

The app is built on javascript but I am using laravel to store data into a database. I am new to nodejs so I am pretty sure if I wanted, I think I could cut out php and just use the whole app with nodejs, but I don't want to. I like laravel and php and it's alread setup, so let me explain my problem.

laravel is installed on my server http://example.com/public/ laravel's index.php is here. My routes for my data base resources are http://example.com/public/feeds. I can access this fine, but if I want to access my nodejs server I need to use http://example.com:3000 which obviously causes a problem.

The nodejs/expressjs files are inside http://example.com/public/MY-FILES-HERE but since the nodejs dispatches on http://example.com:3000 this throws my laravel routes off.

So what I am asking is how do I get it all to work well with eachother? I assume I need to setup a port somehow in laravel.

EDIT: So I am new to the port, and I didnt know there is already a default port set (80). My laravel install is on port 80, and inside here I can listen to calls from port 3000 using socket.io. I did not know that, so I have a page http://my-server-ip:3000/test which has one button and a script that sends the event to the nodejs server and that responds to my script which listens to events on port 3000 and executes a function. Cool stuff here, I hope I made sense I am very new.

图片转代码服务由CSDN问答提供 功能建议

我正在使用nodejs,expressjs和socket.io我用手机在我的网络应用程序上触发事件 在nodejs服务器上。

该应用程序是基于javascript构建的,但我使用laravel将数据存储到数据库中。 我是nodejs的新手,所以我很确定如果我想要,我想我可以删除php并且只使用nodejs的整个应用程序,但我不想。 我喜欢laravel和php以及它的alread设置,所以让我解释一下我的问题。

我的服务器上安装了laravel http://example.com/public/ laravel的index.php就在这里。 我的数据库资源的路由是 http://example.com/public/feeds 。 我可以访问这个,但如果我想访问我的nodejs服务器,我需要使用 http://example.com:3000 ,这显然会导致问题。 < p> nodejs / expressjs文件位于 http://example.com/public/MY-FILES-HERE 中,但由于nodejs调度 http://example.com:3000 < / code>这会抛弃我的laravel路线。

所以我要问的是如何才能让它与彼此一起运作良好? 我假设我需要在laravel中以某种方式设置一个端口。

编辑:所以我是该端口的新手,我不知道已经有一个默认端口 集(80)。 我的laravel安装在端口80上,在这里我可以使用socket.io监听来自端口3000的调用。 我不知道,所以我有一个页面 http:// my-server-ip:3000 / test ,它有一个按钮和一个脚本,可以将事件发送到nodejs服务器并响应 我的脚本,它侦听端口3000上的事件并执行一个函数。 很酷的东西在这里,我希望我有道理我很新。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • donglu5000 2014-01-17 09:53
    已采纳

    Not quite sure what you mean by

    this throws my laravel routes off

    In a situation where you want to host multiple servers on port 80 from the same machine you might want to consider a reverse proxy. I recommend nginx for this.(http://www.cyberciti.biz/tips/using-nginx-as-reverse-proxy.html). Nginx will listen to port 80.

    Then you setup a subdomain eg. node.example.com for the node.js service.

    In the reverse proxy you listen for node.example.com on port 80 and direct that to port 3000. You set up Laravel/Apache? to listen on port 4000 and have nginx listen for www.example.com on port 80 and direct that to port 4000.

    Is this what you are after?

    点赞 打赏 评论

相关推荐 更多相似问题