简体   繁体   English

如何在单个服务器上处理多个域请求?

[英]How to handle multiple domain request on a single server?

I am using dedicated server. 我正在使用专用服务器。 I have hosted different HTML, PHP and wordpress websites on this server those are working perfectly. 我在此服务器上托管了不同的HTML,PHP和wordpress网站,这些网站运行良好。

Now I want to deploy java web application on this server. 现在,我想在此服务器上部署Java Web应用程序。 So I have installed Apache tomcat server on another port. 所以我在另一个端口上安装了Apache tomcat服务器。 So now I want to know how I can handle request directly from domain name to tomcat apache server. 因此,现在我想知道如何直接处理从域名到tomcat apache服务器的请求。

Along with this I want to know how I can deploy multiple web applications on single tomcat. 与此同时,我想知道如何在单个tomcat上部署多个Web应用程序。 I want to know configuration to call different WAR files from tomcat. 我想知道从tomcat调用不同WAR文件的配置。

Thank you in advance for your support. 预先感谢您对我们的支持。

You can use Apache as reverse proxy with the mod_proxy plugin: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html 您可以将Apache用作带有mod_proxy插件的反向代理: http : //httpd.apache.org/docs/2.2/mod/mod_proxy.html

Therefore, you can handle all HTTP requests with Apache, specifying which requests shall be redirected to the Java web app in Apache Tomcat - port 8080. 因此,您可以使用Apache处理所有HTTP请求,并指定应将哪些请求重定向到Apache Tomcat中的Java Web应用程序-端口8080。

Easiest way is to set up a HTTP server (apache, nginx, etc.) as a reverse proxy. 最简单的方法是将HTTP服务器(Apache,nginx等)设置为反向代理。 Then you can map different domains to different contexts, for example: 然后,您可以将不同的域映射到不同的上下文,例如:

www.domain.com -> localhost:8080/main/
www.otherdomain.com -> localhost:8080/othermain/ 
subdomain.domain.com -> localhost:8080/anotherwar/

For example with Nginx it would be done with a ProxyPass directive. 例如,使用Nginx可以通过ProxyPass指令完成。 Other HTTP servers have their own respective mechanisms. 其他HTTP服务器具有各自的机制。

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

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