如何通过端口443处理多个应用程序

对于apache(我们的例子是Oracle的apache版本,OHS),我不是专家,而是在httpd.confredirectinput。 我们在同一台服务器上部署了WLS 10.3.5上的多个应用程序,并希望通过端口443访问它们。

当然,并不是所有的应用程序都可以部署到443,我们会收到一个端口正在使用的错误。

例如,我们在3443上部署了app1,在4443上部署了app2,在5443上部署了app3。我们的客户端希望能够简单地inputhttps:/// app1(或app2或app3)而不是https://: 3443 / app1(或:4443 / app2或:5443 / app3)。

是否有可能在httpd.conf(或ssl.conf)中做到这一点? 是否有可能让URL只使用443,然后在conf文件中redirect到应用程序实际部署的位置(3443,4443和5443)?

这当然可以实现,你的方式取决于你的应用程序的运行方式; 如果它们是由您的Web服务器在某些端口上监听的,那么您需要修改您的configuration以使用类似于以下内容的VirtualHost:

 <VirtualHost *:443> ServerAlias app1.com DocumentRoot /var/www/html/app1 #or however this app is configured [the rest of your configuration directives for the app] </VirtualHost> <VirtualHost *:443> ServerAlias app2.com [As above but for app2] </VirtualHost> 

而如果您的应用程序由其他正在侦听您注意到的端口的进程提供服务,那么您可以使用类似于上述的结构来设置它,但是使用反向代理通过端口443来提供应用程序,例如:

 <VirtualHost *:443> ServerAlias app1.com ProxyPreserveHost on SSLProxyEngine On ProxyPass / http://localhost:5443/ #change the port here for the app in question ProxyPassReverse / http://localhost:5443/ # change the port here for the app in question SSLEngine on [SSL directives as appropriate for your requirements] </VirtualHost> <VirtualHost *:443> ServerAlias app2.com ProxyPreserveHost on SSLProxyEngine On ProxyPass / http://localhost:5443/ #change the port here for the app in question ProxyPassReverse / http://localhost:5443/ # change the port here for the app in question SSLEngine on [SSL directives as appropriate for your requirements] </VirtualHost> 

这样,SSL由Web服务器处理,并将http请求传递回正在监听端口的应用程序,并通过请求的主机名区分应用程序。 值得注意的是,如果应用程序正在侦听这些端口并仅通过SSL进行回复,那么最好从它们中禁用SSL(并按照上面的指示通过Apache运行 – 一旦configuration好了,当然也要closures防火墙中的端口如果他们目前正在外部打开)。

如果你使用的是OHS,那么最好使用代理插件mod_wl_ohs.conf文件来做反向代理。 在mod_wl_ohs.conf中,你可以添加下面的行

在这里输入图像说明

有关详细信息,请参阅http://docs.oracle.com/cd/E28280_01/web.1111/e37889/oracle.htm#PLGWL510

通过这个,你不再需要额外的虚拟主机,并使用OHS 443路由到多个weblogic实例

从描述您的情况的方式来看,这可以通过ProxyPass完成。 它是一个允许redirecturl请求的apache模块。 这里是apache.org信息

对于每个虚拟主机,即: https://app1您将添加到虚拟主机设置

 ProxyPass / https://app1:3443 ProxyPassReverse / https://app1:3443 

有几个很好的HowTo网站。 但是,这应该让你在正确的方向

如果他们不关心url如何结束,你也可以使用mod_rewrite将它们redirect到正确的URL。 我用这个语法不好,给你一个例子。

编辑:

对于1个服务器主机别名。 将可以基于该网站redirect

 <VirtualHost *:443> ServerAlias myserver.com ProxyPreserveHost on SSLProxyEngine On ProxyPass /app1 http://localhost:3443/app1 #change the port here for the app in question ProxyPassReverse /app1 https://localhost:5443/app1 # change the port here for the app ProxyPass /app2 https://localhost:4443/app2 ProxyPassReverse /app2 https://localhost:4443/app2 ProxyPass /app3 https://localhost:5443/app3 ProxyPass /app3 https://localhost:5443/app3 SSLEngine on [SSL directives as appropriate for your requirements] </VirtualHost>