Ok I have a set up a working apache-virtual host configuration, which redirects the users on IP request. The setup is the following:
好的我已经设置了一个有效的apache-virtual主机配置,可以根据IP请求重定向用户。设置如下:
<VirtualHost *:80>
DocumentRoot "C:\wamp\www\dns"
ServerName ConnectToServer
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
The thing is that I want the apache server to redirect to the NodeJS server on request of a specific subdomain.
问题是我希望apache服务器根据特定子域的请求重定向到NodeJS服务器。
For example, apache will redirect to nodeJs server if the user requests www.*.com but I want it to redirect to the server when a subdomain like www.*.com/question is requested.
例如,如果用户请求www.*.com,apache将重定向到nodeJs服务器,但我希望在请求子域(如www.*.com/question)时将其重定向到服务器。
So, how to setup a Name-Based Virtual Host?
那么,如何设置基于名称的虚拟主机?
All I would like to know guys if this practice,making my server available through apache is good for production or should I find another solution like heroku or ngix? ?
所有我想知道的是,如果这种做法,通过apache使我的服务器可用于生产,或者我应该找到像heroku或ngix的其他解决方案? ?
1 个解决方案
#1
2
There are a few ways to do this. I wouldn't recommend putting Apache in front of Node however. Nginx is better, but not really necessary anymore. What I do on my server is run a Node proxy in front of my Node apps and my Apache sites.
有几种方法可以做到这一点。我不建议将Apache放在Node前面。 Nginx更好,但不再需要了。我在我的服务器上做的是在我的Node应用程序和我的Apache站点前面运行一个Node代理。
More details about how I implement this can be found in this answer: How to use vhosts alongside node-http-proxy?
有关如何实现此问题的更多详细信息,请参阅以下答案:如何在node-http-proxy旁边使用vhost?
Apache -> Node
<VirtualHost *:80>
ServerName www.question.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /answer>
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
#1
2
There are a few ways to do this. I wouldn't recommend putting Apache in front of Node however. Nginx is better, but not really necessary anymore. What I do on my server is run a Node proxy in front of my Node apps and my Apache sites.
有几种方法可以做到这一点。我不建议将Apache放在Node前面。 Nginx更好,但不再需要了。我在我的服务器上做的是在我的Node应用程序和我的Apache站点前面运行一个Node代理。
More details about how I implement this can be found in this answer: How to use vhosts alongside node-http-proxy?
有关如何实现此问题的更多详细信息,请参阅以下答案:如何在node-http-proxy旁边使用vhost?
Apache -> Node
<VirtualHost *:80>
ServerName www.question.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /answer>
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>