Apache和文书上士内置应用程序的NodeJS在同一台服务器上...虚拟主机?上士、文书、应用程序、虚拟主机

2023-09-13 03:33:33 作者:可以撩的小姐姐

我一直在试图增加一个应用程序的NodeJS(由约曼内置 - 角fullstack发电机)我的Apache服务器上。我发现这个其他回答的问题: Apache和Node.js的上同一服务器建议使用的ProxyPass是这样的:

I've been trying to add a NodeJS app (built by Yeoman - angular-fullstack generator) on my apache server. I've found this other answered question : Apache and Node.js on the Same Server suggesting to use ProxyPass like this :

ProxyPass /node http://localhost:8000/

当我这样做,我遇到的问题是,我的应用程序开始于一个index.html至极包括与HREF一些文件。由于这些的HREF不启动像这样

The problem I encounter when I do that is that my app starts on an index.html wich includes some files with href. Since these hrefs doesn't start like this

href="/node/..."

它们不是PROXYPASS重定向,从而导致404错误。

They aren't redirected by Proxypass, and thus result in a 404 error.

我不能改变所有的HREF:这将意味着我需要做一遍它在我3环境:开发,生产和测试,即使我这样做,每次我会用步兵测试我的应用程序,它会自动重建我的index.html反正。 (此外,它不能解决一切,也有一些问题socketio出现,当我做到这一点)

I can't just change all the hrefs : that would mean I need to do it all over again on my 3 environment : development, production and test, and even if I did that, everytime I'll use Grunt to test my app, it automatically rebuild my index.html anyway. (Besides, it doesn't solve everything, there are some problems with socketio appearing when I do that)

我唯一能做的,然后使用的ProxyPass是这样的:

Only thing I can do then is using ProxyPass like this :

ProxyPass / http://localhost:8000/

有它的作品,绝对没有问题,就像如果我实际上是使用的应用程序从我的本地主机上的服务器。

There it does works, absolutely no problem, just like if I actually was using the app on from my server on localhost.

剩下的唯一问题是,我需要有我的服务器上2环境,对生产和对测试,我不能这样做。

The only remaining problem is that I need to have 2 environments on my server, on for production and on for tests, and I just can't do

ProxyPass / http://localhost:8000/
ProxyPass / http://localhost:8001/

这显然是行不通的,因为一切都将被重定向到端口8000 bvefore什么都可以达到第二行。

It obviously won't work since everything will be redirected to port 8000 bvefore anything can reach the second line.

所以,我只剩下两个选择:

So, I'm left with only two options :

要么找到一个比使用其他解决方案/作为准则重定向到本地主机:8000,将相同的方式工作,(我没发现什么工作)

Either find another solution than using "/" as criterion for redirecting to localhost:8000 that would work in the same manner (and I didn't find anything working)

或者使用虚拟主机......那还有另一个问题:我真的不是舒适与网络的问题,从我的理解,有在同一台机器上多个虚拟主机,我需要几个CNAMES(每个虚拟主机),但我不知道如何列出/加CNAMES(我的服务器Windows Server 2008上没有访问万维网上运行),而我没有在我的管理工具中的DNS应用因为我应该按照这个来: https://technet.microsoft.com /en-gb/library/cc753579.aspx

Or use virtual hosts... And there goes another problem : I'm really not confortable with network issues, from what I understood, to have several virtual hosts on the same machine, I need several CNAMES (one for each virtual hosts), but I don't know how to list / add CNAMES (my server runs on Windows Server 2008 with no access to the world wide web), and I don't have any "DNS" application in my "Administrative Tools" as I'm supposed to according to this : https://technet.microsoft.com/en-gb/library/cc753579.aspx

任何帮助将是非常欢迎在此先感谢!

Any help would be very welcome Thanks in advance !

编辑:我真的觉得我的解决办法是抽搐我的Apache配置。任何人都可以用来处理服务器CONFIGS帮助我吗? :/

EDIT : I really think that my solution is to twitch my Apache configuration. Can anyone used to deal with server configs help me? :/

推荐答案

好像所有我缺少的是一个

Seems like all I was missing was a

<base href="/node/">

标签(甚至不知道它,约曼是创建者)

tag (didn't even know about it, and Yeoman created it as )

我还有一个问题,但:

Socket.io ......我真的不这里得到我自己的问题:它在node_modules(至极是正常的,因为我需要它在我的服务器和我的客户),而是试图将它作为我这样做之前使用基本href失败。我甚至不明白怎么做前工作:(index.html的:)&LT;脚本SRC =socket.io的客户端/ socket.io.js&GT;&LT; / SCRIPT&GT; 这似乎并不正确知道我的项目文件夹是这样的:

Socket.io ... I don't really get my own problem here : it's in node_modules (wich is normal since I need it in my server and my client), but trying to include it as I was doing so before using base href fails. I don't even get how it did work before : (index.html : ) <script src="socket.io-client/socket.io.js"></script> This doesn't seem right knowing my project folder is like this :

[项目根]

-client

- index.html的

--index.html

-node_modules

-node_modules

- socket.io客户端

--socket.io-client

--- socket.io.js

---socket.io.js