简体   繁体   English

在另一个Web服务器上运行Apache?

[英]Running Apache alongside another web server?

Has anyone had any success running two different web servers -- such as Apache and CherryPy -- alongside each other on the same machine? 有没有人在同一台机器上运行两个不同的Web服务器(如Apache和CherryPy)并没有成功? I am experimenting with other web servers right now, and I'd like to see if I can do my experiments while keeping my other sites up and running. 我现在正在尝试其他网络服务器,我想看看我是否可以在保持其他网站正常运行的同时进行实验。 You could say that this isn't so much a specific-software question as it is a general networking question. 你可以说这不是一个特定的软件问题,因为它是一个普通的网络问题。

  • I know it's possible to run two web servers on different ports; 我知道可以在不同的端口上运行两个Web服务器; but is there any way to configure them so that they can run on the same port (ie, they both run on port 80)? 但有没有办法配置它们,以便它们可以在同一个端口上运行(即,它们都在端口80上运行)?
  • The web servers would not be serving files from the same domains. Web服务器不会提供来自相同域的文件。 For example, Apache might serve up documents from foo.domain.com, and the other web server would serve from bar.domain.com. 例如,Apache可以从foo.domain.com提供文档,而另一个Web服务器可以从bar.domain.com提供。

I do know that this is not an ideal configuration. 我知道这不是一个理想的配置。 I'd just like to see if it can be done before I go sprinting down the rabbit hole. 我想看看是否可以在我冲下兔子洞之前完成它。 :) :)

You can't have two processes bound to the same port on the same IP address. 您不能将两个进程绑定到同一IP地址上的同一端口。 You can add another IP address to the box and have each server listen on one. 您可以在框中添加另一个IP地址,让每个服务器监听一个。

Another option is to proxy pass one server to the other. 另一种选择是代理将一台服务器传递给另一台服务器。 With Apache, you could do something like: 使用Apache,您可以执行以下操作:

NameVirtualHost *
<virtualhost *>
  ServerName other.site.com

  # assumes CherryPy listens on port 8080
  ProxyPass / http://127.0.0.1:8080/
  ProxyPassReverse / http://127.0.0.1:8080/
</Virtualhost>

That's a pretty quick example, but you can always check the ProxyPass documentation . 这是一个非常快速的示例,但您始终可以查看ProxyPass文档 Remember though, the application being proxyed to will get 127.0.0.1 in it's logs instead of the requester's IP address. 但请记住,被代理的应用程序将在其日志而不是请求者的IP地址中获得127.0.0.1。 Some web servers (apache does with mod_rpaf ) can substitute the X-Forwarded-For header in place of the wrong IP address. 某些Web服务器(apache使用mod_rpaf )可以替换X-Forwarded-For标头代替错误的IP地址。 Possibly CherryPy has this? 可能CherryPy有这个吗?

Your best bet would be putting Apache httpd in front of port 80 and relay requests meant for other servers through Apache by using modules. 最好的办法是将Apache httpd放在端口80前面,并通过使用模块通过Apache中继其他服务器的请求。 Most popular scenario would be Tomcat behind Apache where you'll be able to run both php and jsp applications. 最流行的场景是Apache背后的Tomcat,你可以运行php和jsp应用程序。

I'm not familiar with CherryPy, so I can only suggest you look for an Apache module for CherryPy. 我不熟悉CherryPy,所以我只建议你为CherryPy寻找一个Apache模块。

Edit: This looks promising: http://tools.cherrypy.org/wiki/BehindApache 编辑:这看起来很有希望: http//tools.cherrypy.org/wiki/BehindApache

或者,对于Ishmaeel的正确答案,如果您的服务器有2个网卡,则可以让每个服务器在不同的IP地址上应答请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM